Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Fedora server with a USB backup drive connected to it. I have managed to mount the drive and want to run a daily backup of my MySql database. I am completely new to cron jobs and really need some help please.

Cheers.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The crontab syntax is really easy to understand. Just try it.

For the backup of your MySQL databases you could just use mysqldump which is shipped with MySQL. There are more sophisticated means of making backups of a MySQL database but mysqldump should just do fine for you.

share|improve this answer
    
Thanks for response, so if I type the following into the shell it should back up the db 1 minute past 12. 1 0 * * * mysqldump -u -p [database] > /usbdrive/bk.sql If this is right how would I set the dates in the .sql file name? Cheers –  user20996 Jan 4 '10 at 14:31
    
You could use date for this, e. g. /usr/bin/mysqldump -u [user] -p [pass] [database] > /usbdrive/backup-$(date +'\%F').sql. –  joschi Jan 4 '10 at 14:59
    
Cheers joschi, added it to crontab and tested it every 5 mins and working so now set it to 1 minute past 12 o'clock at night so hopefully it will work. Thanks again. –  user20996 Jan 4 '10 at 15:35

On top of what joschi said, once you use mysqldump to generate the backup file, you can do a lot of other things with it.

What I used to do was to email myself the database as an attachment using mutt, daily. Of course this depends on the size of your databases but it did give me an off-site backup solution.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.