Wednesday, April 8, 2009

How to Backup MySQL Database automatically in linux

The command for back up a mysql database is:

15 2 * * * root mysqldump -u root -pPASSWORD --all-databases | gzip > /mnt/disk2/database_`data '+%m-%d-%Y'`.sql.gz

The first part is "15 2 * * *". The five fields mean "minute, hour, day of month, month, day of week" respectively. The character '*' stands for "any".
The next, "root", means "run following command as root account".

You can use cron job so that it takes backup daily.

No comments: