Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I want to automatize 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.gz

svn 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

Any other tip ? thanks

share|improve this question
If you are using a public svn server please consider encrypting the backups with GPG before committing. –  João Pinto Jan 3 '11 at 12:04
@João Pinto Thanks for tip. It is a private one.. –  Patrick Jan 3 '11 at 12:13
Is there a good reason for you to use svn to store the backups ? I don't see any benefit from using a revision control system to manage a single binary file. –  João Pinto Jan 3 '11 at 12:26
MySQL dumps are not binary, but a text file with all the SQL statements (CREATE TABLE, INSERT, etc...) needed to recreate the database. –  Javier Rivera Jan 3 '11 at 12:29
@João Pinto I'm using SVN to make backup of several folders and I need somehow to include the database as well. So I'm making a dump and committing it as file. –  Patrick Jan 3 '11 at 12:31

1 Answer 1

up vote 0 down vote accepted

1) The mysql dump for backup itself is the usual approach, I don't see any benefit from using svn to store the backups

2) Better move this to it's own question (svn related)

3) By doing the commands in sequence in a script you are already enforcing that, the svn commit is only executed after the mysqldump | gzip finishes .

share|improve this answer

Your Answer


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.