Backup Cron Job

Mike Starke plug-discuss@lists.plug.phoenix.az.us
Mon, 23 Sep 2002 20:20:25 -0500


As someone else mentioned, there should be no need to stop/start mysql.

I run something like this in a crontab:

45 0 * * * mysqldump --opt mydb > /data/dumps/mydb_`date \+\%j-\%H-\%M.dump`

For something like this (above) to work you would assumne the db is local 
and you either have no password (bad) or a password in your .my.cnf file.
Check all the other options for mysqldump as well.

The format of the file the above command write is:
mydb_DayOfYear-hour-minute.dump
For instance, today's file should be: mydb_266-00-45.dump

I run the same command for each db on the system. The mysql
database, which never changes on my system, also get's dumped
each night, and then I run it against diff to alert me for
any hanky panky.

Set up the filename and frequency so suit your tastes; then simply
tar the file to your device. I have a jazz drive that I run everything to
every week (backups are to a seperate drive like you are doing), and a simple
'tar -cvf /dev/device /data/*' will run it onto disk for you. Change the "c"
parameter in tar to suit your needs as well (u or r?).

My backup is quite simple, not very eloquent, but then again, I have never
lost any data.

Maybe look into 'mt' to get a status on the tape drive. When I first
installed Linux, I had an old floppy tape drive that I backed up to;
I too needed to get a disk usage from the device. I spent 2 days
writing a Perl script which massaged the output of 'tar -tvf ..'
into something that would give me an idea of what percentage
of space I had on the tape drive........then I discovered 'mt' :-)

Hopefully, this should be enough to get you started.

v/r
Mike





On Mon, Sep 23, 2002 at 01:38:05PM -0700, Phil Mattison wrote:
 Hello Fellow PLUGers,
   I have a Linux server running Apache/PHP/MySQL, and want to setup
 automatic daily backups for the database. I'm planning to install a second
 hard drive to receive the backup data, and will modify the web site to
 exclude access while backups occur. I'm wondering if anyone has written
 scripts to do similar tasks and would be willing to share some examples. I'm
 thinking the script needs to do something like the following:
 Stop MySQL
 Copy the database files to the backup drive
 Restart MySQL
   It also would be nice to get a daily report of disk usage and the size of
 the backups. If anyone has any tips or examples they would be much
 appreciated.
 Thanks,
 --
 Phil Mattison
 Ohmikron Corp.
 480-722-9595
 602-820-9452 Mobile
 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
 To subscribe, unsubscribe, or to change  you mail settings:
 http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss