What will be code for adding a Cron for Backing up databases?
What will be code for adding a Cron for Backing up databases? And I want the the backup file in this format 'dd-mm-yy.sql.gz', so what should be the code?
-
You could add the UAPI commandline option to complete a backup: UAPI Functions - Backup::fullbackup_to_homedir - Developer Documentation - cPanel Documentation Format is: [QUOTE] - YYYY represents the year.
- MM represents the month.
- DD represents the date.
- HH represents the hour.
- mm represents the minute.
- ss represents the second.
- username represent's the account's username.
0 -
To dump the database with .sql.gz format use the below command mysqldump -u username -pPassword dbname | gzip > backup_db_`date +%F`.sql.gz Save it as a sh file for eg: mysqlbackup.sh and then set a cron like below to execute the cron on every Saturday on 00:00 hours. Edit the cron settings based on your requirement. 0 0 * * 6 /bin/sh /root/mysqlbackup.sh 0
Please sign in to leave a comment.
Comments
2 comments