cPanel offers a cron that allows you to run your commands or scripts automatically at certain times. You can choose the time per your requirement, that could be every month, every week or every day. A database stores the critical information of your website. Therefore, you should take a backup of your database at regular intervals. Please refer to the following steps on how to set up MySQL database backup daily.
1. Log in to your cPanel.
2. Go to Advanced and click Cron Jobs.
3. In the Cron Jobs section, you will see the Cron Email option. It can send an email every time cron runs a command which produces output. If you do not want an email sent for an individual cron job, you can redirect the command’s output to /dev/null. For example, yourcommand >/dev/null 2>&1. You can enter your email account for this.
4. At the add new corn job and common settings, select once per day.
5. Now, in the command box, enter the below command.
mysqldump -uroot -ppassword --opt accu_4 > /home/mysql_backup/accu_4-$( date +"\%Y_\%m_\%d" ).sql
You will need to make the following changes in your command.
root: Change it to your database user.
password: Change it to your database user password
accu_4: Change it with your actual database name.
/home/mysql_backup/ : Path where the backup file will be added. You can change the path as per your requirement.
6. Click on Add New Cron Job button. cPanel cron will take the backup of your database daily at 00:00.
You are done with MySQL database backup using cPanel cron.