|
Taking backup of mysql database using cron |
|
Tuesday, 20 September 2005 |
Taking backup of mysql database using cron
Create a file called database_backup.sh and also an empty directory called mysql_backup.
The database_backup.sh script should have the following info :
-------------------------------------------------
#!/bin/sh
date=`date '+%m-%d-%y'`
mysqldump -u database_username -pdatabase_password database_name > ~/mysql_backup/database_name.$date
-------------------------------------------------
Run the script that performs the backup job.
-------------------------------------------------
* 23 * * * your_userid /path/to/backup/script
-------------------------------------------------
Set this script up to run every night, etc. as a cron job. It will save an
sql dump of your database every night in the mysql_backup. |