GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   MySQL automatic backup script I can run?? (https://gfy.com/showthread.php?t=779116)

Juicy D. Links 10-24-2007 10:18 AM

MySQL automatic backup script I can run??
 
Anybody have a good one i can execute via the shell and also option to run daily via cron?











Ice is gay

bns666 10-24-2007 10:25 AM

bump i need this tooooooooooo.

psili 10-24-2007 10:34 AM

Not sure about InnoDB tables, but can't you put the following in a shell script:

mysqldump --user=[user] --pass=[pass] --opt [database] > /path/to/backup.sql

Juicy D. Links 10-24-2007 10:34 AM

Quote:

Originally Posted by bns666 (Post 13281093)
bump i need this tooooooooooo.

i am googling now , se if i can find something

Juicy D. Links 10-24-2007 10:35 AM

Quote:

Originally Posted by psili (Post 13281152)
Not sure about InnoDB tables, but can't you put the following in a shell script:

mysqldump --user=[user] --pass=[pass] --opt [database] > /path/to/backup.sql

hmm that looks ripe. i try it

the alchemist 10-24-2007 10:40 AM

To back-up all db's:

mysqldump --all-databases > all_databases.sql

directfiesta 10-24-2007 10:41 AM

http://www.debianhelp.co.uk/mysqlscript.htm

Juicy D. Links 10-24-2007 11:21 AM

niceeeeeeeeeeeee

SuckOnThis 10-24-2007 11:35 AM

Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.



#!/bin/sh

# List all of the MySQL databases that you want to backup in here,
# each seperated by a space
databases="name of database"
# Directory where you want the backup files to be placed
backupdir=/path/to/directory

# MySQL dump command, use the full path name here
mysqldumpcmd=/usr/bin/mysqldump

# MySQL Username and password
userpassword=" --user=username --password=your password"

# MySQL dump options
dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"

# Unix Commands
gzip=/bin/gzip
uuencode=/usr/bin/uuencode
mail=/usr/sbin/sendmail

# Send Backup? Would you like the backup emailed to you?
# Set to "y" if you do
sendbackup="n"
subject="Your MySQL Backup"
mailto="[email protected]"

# Create our backup directory if not already there
mkdir -p ${backupdir}
if [ ! -d ${backupdir} ]
then
echo "Not a directory: ${backupdir}"
exit 1
fi

# Dump all of our databases
echo "Dumping MySQL Database"
for database in $databases
do
$mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${database}.dump
done

# Compress all of our backup files
echo "Compressing Dump File"
for database in $databases
do
rm -f ${backupdir}/${database}.dump.gz
$gzip ${backupdir}/${database}.dump
done

# Send the backups via email
if [ $sendbackup = "y" ]
then
for database in $databases
do
$uuencode ${backupdir}/${database}.dump.gz > ${backupdir}/${database}.dump.gz.uu
$mail -s "$subject : $database" $mailto < ${backupdir}/${database}.dump.gz.uu
done
fi


# And we're done
ls -l ${backupdir}
echo "Dump Successful and Complete!"
exit

Juicy D. Links 10-24-2007 11:37 AM

Quote:

Originally Posted by SuckOnThis (Post 13281525)
Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.



#!/bin/sh

# List all of the MySQL databases that you want to backup in here,
# each seperated by a space
databases="name of database"
# Directory where you want the backup files to be placed
backupdir=/path/to/directory

# MySQL dump command, use the full path name here
mysqldumpcmd=/usr/bin/mysqldump

# MySQL Username and password
userpassword=" --user=username --password=your password"

# MySQL dump options
dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"

# Unix Commands
gzip=/bin/gzip
uuencode=/usr/bin/uuencode
mail=/usr/sbin/sendmail

# Send Backup? Would you like the backup emailed to you?
# Set to "y" if you do
sendbackup="n"
subject="Your MySQL Backup"
mailto="[email protected]"

# Create our backup directory if not already there
mkdir -p ${backupdir}
if [ ! -d ${backupdir} ]
then
echo "Not a directory: ${backupdir}"
exit 1
fi

# Dump all of our databases
echo "Dumping MySQL Database"
for database in $databases
do
$mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${database}.dump
done

# Compress all of our backup files
echo "Compressing Dump File"
for database in $databases
do
rm -f ${backupdir}/${database}.dump.gz
$gzip ${backupdir}/${database}.dump
done

# Send the backups via email
if [ $sendbackup = "y" ]
then
for database in $databases
do
$uuencode ${backupdir}/${database}.dump.gz > ${backupdir}/${database}.dump.gz.uu
$mail -s "$subject : $database" $mailto < ${backupdir}/${database}.dump.gz.uu
done
fi


# And we're done
ls -l ${backupdir}
echo "Dump Successful and Complete!"
exit

thats niceeee save as a .sh file and execute via SSH right? :pimp

GrouchyAdmin 10-24-2007 11:38 AM

What's this about my Ass Queue? I'm not very good with computars.

SuckOnThis 10-24-2007 11:54 AM

Quote:

Originally Posted by Juicy D. Links (Post 13281538)
thats niceeee save as a .sh file and execute via SSH right? :pimp

You can execute it with SSH or run it as a cron.

Just be sure to enter the correct info for 'databases', 'backupdir', 'user', and 'password'

Juicy D. Links 10-24-2007 11:55 AM

script above is rippeee works hotttttt thxxxx

Juicy D. Links 10-24-2007 11:57 AM

Quote:

Originally Posted by SuckOnThis (Post 13281627)
You can execute it with SSH or run it as a cron.

Just be sure to enter the correct info for 'databases', 'backupdir', 'user', and 'password'


yup did that

thxxxxxxxxxxxxx

Juicy D. Links 10-24-2007 12:00 PM

Dump Successful and Complete!

HomerSimpson 10-24-2007 01:22 PM

I could write you a custom one ;)

Tempest 10-24-2007 03:41 PM

Quote:

Originally Posted by SuckOnThis (Post 13281525)
Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.

Sweet script...

I have one I wrote in Perl that also tars all the DBs together and then Zips it. They get saved with a datestamp as well so I can roll back a few days if need be. At some point I'm going to upgrade it to also FTP the DB backup to another server so if one goes down I still have backups.

GrouchyAdmin 10-24-2007 03:49 PM

Quote:

Originally Posted by Tempest (Post 13282854)
Sweet script...

I have one I wrote in Perl that also tars all the DBs together and then Zips it. They get saved with a datestamp as well so I can roll back a few days if need be. At some point I'm going to upgrade it to also FTP the DB backup to another server so if one goes down I still have backups.

Why the hell did you use Perl?

Code:

-rwx------ 1 root root 3426 2007-09-29 13:16 backer.sh
This little 3.5k shell script does daily, weekly, monthly, and yearly backups, compresses them all, and keeps any amount of 'snapshots' you want, and offers automated redundancy with rsync and ncftpput. :thumbsup

bDok 10-24-2007 04:26 PM

nice shell script above.. perfect for making a gmail account for the database and shipping it off to that account daily or whenever you want to run it from the cron.

quality reply there. cheers.

Juicy D. Links 10-24-2007 04:42 PM

all this code talk is getting me HARD

Juicy D. Links 10-24-2007 04:43 PM

all this code talk is getting me HARD

Juicy D. Links 10-24-2007 04:43 PM

all this code talk is getting me HARD

Tempest 10-24-2007 04:52 PM

Quote:

Originally Posted by GrouchyAdmin (Post 13282898)
Why the hell did you use Perl?

Code:

-rwx------ 1 root root 3426 2007-09-29 13:16 backer.sh
This little 3.5k shell script does daily, weekly, monthly, and yearly backups, compresses them all, and keeps any amount of 'snapshots' you want, and offers automated redundancy with rsync and ncftpput. :thumbsup

ha ha ha.. why? Cause I know perl and do a LOT of little scripts with it so it's just second nature to me... I know very little about what's already available on most servers/OSs.. and I'm not great writing cross-OS shell scripts.

Couldn't find backer.sh on one of my FreeBSD and Linux servers.

GrouchyAdmin 10-24-2007 05:46 PM

Quote:

Originally Posted by Tempest (Post 13283140)
Couldn't find backer.sh on one of my FreeBSD and Linux servers.

That would be because I made it. :1orglaugh :thumbsup

If you always design for the least common amount of bourne compatibility, the shells will usually work. Don't rely on linux or BSD nuances by themselves, test if you have to, and abusing awk is never wrong. :thumbsup

papill0n 10-24-2007 05:52 PM

Quote:

Originally Posted by SuckOnThis (Post 13281525)
Here Juicy, this works fine. You can even have it email you the dump file if you want or just have it saved on the server.



#!/bin/sh

# List all of the MySQL databases that you want to backup in here,
# each seperated by a space
databases="name of database"
# Directory where you want the backup files to be placed
backupdir=/path/to/directory

# MySQL dump command, use the full path name here
mysqldumpcmd=/usr/bin/mysqldump

# MySQL Username and password
userpassword=" --user=username --password=your password"

# MySQL dump options
dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables"

# Unix Commands
gzip=/bin/gzip
uuencode=/usr/bin/uuencode
mail=/usr/sbin/sendmail

# Send Backup? Would you like the backup emailed to you?
# Set to "y" if you do
sendbackup="n"
subject="Your MySQL Backup"
mailto="[email protected]"

# Create our backup directory if not already there
mkdir -p ${backupdir}
if [ ! -d ${backupdir} ]
then
echo "Not a directory: ${backupdir}"
exit 1
fi

# Dump all of our databases
echo "Dumping MySQL Database"
for database in $databases
do
$mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${database}.dump
done

# Compress all of our backup files
echo "Compressing Dump File"
for database in $databases
do
rm -f ${backupdir}/${database}.dump.gz
$gzip ${backupdir}/${database}.dump
done

# Send the backups via email
if [ $sendbackup = "y" ]
then
for database in $databases
do
$uuencode ${backupdir}/${database}.dump.gz > ${backupdir}/${database}.dump.gz.uu
$mail -s "$subject : $database" $mailto < ${backupdir}/${database}.dump.gz.uu
done
fi


# And we're done
ls -l ${backupdir}
echo "Dump Successful and Complete!"
exit

very useful - thanks alot for posting that :thumbsup

Juicy D. Links 10-24-2007 07:51 PM

i make great threads

Az A Bay Bay 10-24-2007 07:52 PM

soRRy cant HELP "(

GrouchyAdmin 10-24-2007 07:54 PM

Quote:

Originally Posted by Juicy D. Links (Post 13283764)
i make great threads

Show me one.


All times are GMT -7. The time now is 12:02 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123