I use a perl method for a full week's worth of backups, this could be migrated to have a weekly, monthly, yearly snapshot as well.
#!/usr/bin/perl my $szToday = `date +%a`; chop ($szToday); $dbDumpName = '/var/backup/dbDump.mysql'; $backupFile = '/var/backup/siteFiles'; $siteDir = '/home/dir/of/other/files'; system ("rm -f $dbDumpName\-$szToday.gz"); system ("/usr/local/bin/mysqldump -u fsbo fsbo > $dbDumpName\-$szToday"); system ("gzip $dbDumpName\-$szToday"); system ("rm -f $backupFile\-$szToday.tgz"); system ("tar cfz $backupFile\-$szToday.tgz $siteDir"); -----Original Message----- From: Gerald R. Jensen [mailto:[EMAIL PROTECTED]] Sent: Friday, March 15, 2002 9:49 PM To: Chetan Lavti; [EMAIL PROTECTED] Subject: Re: Script for Data base backup and recovery : Very essential This has been covered here a number of times before ... a search of the archive avoids the need to repeat the same info. That being said ... We use a cronjob (root) that calls a shell script at 3am daily. The line in the cronjob is: * 3 * * * /usr/local/bin/dbbakup.sh username password The shell script: ################################################################# #!/bin/sh # $1 = Unix/MySQL Username # $2 = Unix/MySQL Password if [ ! -e /dbbakup ] then mkdir /dbbakup fi mysqldump -u$1 -p$2 -c --add-drop-table --add-locks --flush-logs --databases account>/dbbakup/account.sql mysqldump -u$1 -p$2 -c --add-drop-table --add-locks --flush-logs --databases payroll>/dbbakup/payroll.sql mysqldump -u$1 -p$2 -c --add-drop-table --add-locks --flush-logs --databases contact>/dbbakup/contact.sql ################################################################# If you wanted to ftp the resulting scripts to another server, you could add code to the shell script to run ncftpput, etc. Gerald Jensen ----- Original Message ----- From: "Chetan Lavti" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, March 12, 2002 11:16 PM Subject: Script for Data base backup and recovery : Very essential hi, Can anybody tell me how can I write script for MySQL backup and recovery.( i am newbie as per script is cencern) I am using Innodb table type and using all the default parameters specified in the my.cnf file (my-large.cnf) Looking for kind response.. Thanks and regards, Chetan Lavti --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <mysql-unsubscribe-##L=##[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php