How do I create a MySQL back-up using a cPanel Cron Job command and give each back up a new name so as not to overwrite the old file?
After a lot of searching and tweaking I managed to create a command so that every time a new MySQL back-up is created, the old back up is preserved.
It is easy enough to create a Cron Job using cPanel to create a back-up,. Just use the following Cron Job command and give it the time intervals you want it to run, using the ‘common settings':
mysqldump -u DATABASE_USER -pDATABASE_PASSWORD DATABASE_NAME > /home/user/sql-backups-folder/file-name.sql
But I want give every backup a new name. What I will do is add to the command line as follows:
mysqldump -u DATABASE_USER -pDATABASE_PASSWORD DATABASE_NAME > /home/user/sql-backups-folder/file-name_`date ‘+\%Y-\%m-\%d-\%H-\%M-\%S’`.sql
Now every backup will be given a new file name in the following format
Which is the file name plus the Year, Month, Day, Hour, Minute, Second.