Search code examples
unixcronmysqlcron-task

Adding the time to mysqldump cron job?


The following works:

/usr/bin/mysqldump -u[username] -p[password] --all-databases --single-transaction > /home/[domain]/public_html/backups/full_backup_`date -I`.sql

It results in "full_backup_2012-11-04.sql"

The cron job is going every minute but the filename is only for once a day... I wanted to include the hour and minute in the filename as well.... (in the end the cron job might be run every hour or so)

So date -I works... other typical options for date don't seem to work... is there any documentation that says -I is valid? If so that documentation might also have other options that work.


Solution

  • date -Iminutes could be the way to go, which uses ISO 8601 format. The Wiki page has some info.