Aug 13, 2011

Automate the backup of my databases and files with cron


I want to automate the backup of my databases and files with cron.
Should I add the following lines to crontab ?

mysqldump -u root -pPASSWORD database_name | gzip > /home/backup/database_`date +%m-%d-%Y`.sql.gzsvn commit -m "Committing the working copy containing the database dump"
  1. First of all, is this a good approach?

  2. It is not clear how to specify the repository and the working copy with svn?

  3. How can I run svn only when the mysqldump is done and not before ? Avoiding conflicts


1) If you insist on storing backups in subversion, then there is nothing wrong with this approach. It is strange, though.

2) You should keep a checkout around, place the dump into the working directory, and run svn update and svn add as appropriate before committing.

3) If you run the commands as shown from a shell script, there should be no overlap.

Related posts:

  1. Automate svn checkout with SSH
  2. What user do scripts in the cron folders run as? (i.e. cron.daily, cron.hourly, etc)
  3. Passing date/time to cron job command
  4. SVN Server occupying a lot of space
  5. Bash Script Won’t Run in Cron

Leave a comment