|
2005-07-28, 07:25 PM | #1 |
Verbal prefers 56K
|
How to setup Cron to backup MySQL DBs
Can someone explain or link a tuorial on how to backup all my MySQL databases with a Cron? I'd like to back them up like Mon, Wed, Fri and have a copy emailed to me. I think this is just a matter of automating mysqldump on all the db's, but I haven't set this up before. Thanks.
__________________
Verbal |
2005-07-28, 08:17 PM | #2 |
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
crontab entry:
0 1 * * 1,3,5 /usr/bin/mysqldump -q -u username -p"password" databasename > /tmp/file.sql;gzip /tmp/file.sql;/var/www/email.pl email.pl Code:
#!/usr/bin/perl -w use MIME::Lite; $msg = MIME::Lite->new( From => 'user@domain.com', To => 'user@domain.com', Subject => 'mysql backup', Type => 'text/plain', Data => "backups attached"); $msg->attach(Type=>'application/x-tar', Path =>"/tmp/file.sql.gz", Filename =>"file.sql.gz"); $msg->send;
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
2005-07-29, 11:28 PM | #3 |
Verbal prefers 56K
|
Thanks for the info cd34! Time to start automating these things.
__________________
Verbal |
2005-07-30, 12:59 AM | #4 |
Subversive filth of the hedonistic decadent West
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
|
I did it about the same way that cd34 posted but since I learned ho to do rsync I stopped having things mailed to me and just do the database dump to my server's drive. I then have my laptop's cron do rsync each night and keep a mirror of my server on my laptop which includes the database dumps.
I setup seven different dumps each week so that I have seven versions of my databases. |
|
|