Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2005-07-28, 07:25 PM   #1
Verbal
Verbal prefers 56K
 
Verbal's Avatar
 
Join Date: Sep 2003
Location: Chicago, IL
Posts: 563
Send a message via ICQ to Verbal
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
Verbal is offline   Reply With Quote
Old 2005-07-28, 08:17 PM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
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
cd34 is offline   Reply With Quote
Old 2005-07-29, 11:28 PM   #3
Verbal
Verbal prefers 56K
 
Verbal's Avatar
 
Join Date: Sep 2003
Location: Chicago, IL
Posts: 563
Send a message via ICQ to Verbal
Thanks for the info cd34! Time to start automating these things.
__________________
Verbal
Verbal is offline   Reply With Quote
Old 2005-07-30, 12:59 AM   #4
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
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.
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:23 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc