Jeeva Suriyaa
Jeeva Suriyaa

Reputation: 96

Linux Backup MySQL failed when assign to crontab

Hi fellow StackOverFlow,

Today , I have a very weird scenario in my Unix machine.

I'm currently using this command manually to save my current database backup.

/usr/bin/mysqldump -u root -p'thetechnofreak' admin_test > /mnt/databasesql/admin$(date +%Y-%m-%d-%H.%M.%S).sql.gz

In my crontab , I access it using

crontab -e

Then I add the following to the list

30 2 * * * /usr/bin/mysqldump -u root -p'thetechnofreak' admin_test > /mnt/databasesql/admin$(date +%Y-%m-%d-%H.%M.%S).sql.gz

I realize that it's not doing it automatically, is there anything that i've missed?

Is there a flagging option or a logging method to know whether the backup is done successfully or not.

Thanks in advance.

Upvotes: 0

Views: 55

Answers (1)

Drew
Drew

Reputation: 24949

Try this with the escaping of a \ prior to the %

30 2 * * * /usr/bin/mysqldump -u root -p'thetechnofreak' admin_test > /mnt/databasesql/admin$(date +\%Y-\%m-\%d-\%H.\%M.\%S).sql.gz

See Using the % Character in Crontab Entries by M. Ducea

Upvotes: 2

Related Questions