PDA

View Full Version : Backup to CD-RW



simon_r2d2
20th April 2006, 08:36 AM
I have a fully functional and brand new installation of FC5 on a Dell Poweredge server. I am going to be using it to deliver web-based MySQL databases via LAMP.

I would like to be able to bakup the sites and the databases to a CD-RW on a schedule. I regularly take extracts of the databases, but this is not as good as a proper scheduled backup.

Does anyone know of any software which will allow me to dump a MySQL database out to a SQL file with a given filename (i.e. the date the dump is taken) and then write the resulting file to a CD-RW?

Any help greatly appreciated.

Simon

giulix
20th April 2006, 10:12 AM
dumpmysql.sh


#!/bin/sh
#
# Dump and backup MySQL database
#
now=`date +%C%y%m%d%H%M%S`
dumpfilename=$now"-mysql.dmp"
mkdir DBDUMP
mysqldump --opt db_name > DBDUMP/$dumpfilename
mkisofs -r -J -iso-level 4 -p "MySQL dump taken on $now" -o $now"-mysql.iso" DBDUMP
cdrecord dev=ATA:1,0,0 blank=fast
cdrecord -v speed=4 dev=ATA:1,0,0 $now"-mysql.iso"

Name the file as you like, then do a chmod 754 on it. Make sure you run it as root.
There are a few things you'll need to amend, though:
.I know nothing about MySQL. The mysqldump command was taken from its man page. Hope it works, but you'll have to change the database name.
.cdrecord device will probably be different. Run 'cdrecord -scanbus' as root to find out about your CD writer. Once you have found out the LUN for your CD writer, modify the dev= parameter in the two cdrecord commands accordingly.

P.S. I have left out the part on how to schedule the execution of the above script at predefined times/intervals. If you are going to opt for this solution, I will give you details on how to put it in root's crontab.

simon_r2d2
20th April 2006, 12:14 PM
Thanks for this - very helpful indeed.

As for the scheduling, thanks to my limited knowledge of CRON and the rather handy 'Scheduled Tasks' GUI for CRON in FC, I am sorted!!

Many thanks
Simon