August 6th, 2003, 06:37 PM
How to Crontab
I want to use crontab to make daily backups of my mysql database.
But, I donít want it to overwrite the old file.
How do I auto number the files Iím creating ?
Backup - mysqldump database_name -u user_name -ppassword > SQL_Back_XX
Where xx will increment one after another.
August 7th, 2003, 01:10 AM
This is really a Unix shell-scripting issue, not a database one, but one quick way to handle this would be to use dates:
mysqldump database_name -u user_name -ppassword > SQL_Back_`date +%Y_%m_%d`
Note: the single quotes in this are backquotes (the top left key over the Tab). This means that the command inside the quotes is executed, and the result is returned as a string. So, your backup files would look like
You could also add minutes to this if you want several backups a day:
mysqldump database_name -u user_name -ppassword > SQL_Back_`date +%Y_%m_%d_%M`
There are many combinations you can do if you play with the date formatting options. Do a 'man date' for more info.
August 7th, 2003, 04:17 PM
Thanks, Helped a bunch.