Daily Database backup using Cron Job

Hussy picture Hussy · Jul 5, 2011 · Viewed 34.4k times · Source

Hi i want to take database backup at daily mid night using cron job... and the name of database backup should append with current date... the format of backup file should be mydata_yyyy_mm_dd.sql ... backup file should be placed in /root directory

Answer

wonk0 picture wonk0 · Jul 5, 2011

something like

0 0 * * * /path/to/mysqldump ... > /path/to/backup/mydata_$( date +"%Y_%m_%d" ).sql

should work.

Please read

  • man date
  • man 5 crontab