Database Backups Using A Cron Job backup

In this article, we share information about creating a cron job in cPanel to make a database backup. In your cPanel dashboard, users have access to create a cron job backup through a cPanel interface.

Cron is a Linux utility that makes schedules a command or script on your server to run automatically on a specific time and day.

How To Set Up A Cron Job To Backup Your Database

  1. Login to your cPanel account.
  2. You see the advance section on your cPanel dashboard.
Database Backups Using A cron Job
  1. In the advance section, click on the corn jobs.
  2. You’ll need to enter your email address for further notification.
  3. From the drop-down menu option, choose a common setting once per week.
  4. Choose your non-peak traffic hours to run your corn jobs.
  5. Replace the following on your command area:
  • <cPanelUserName> with your cPanel username
  • <FILE_NAME_HOME_DIRECTORY_> from the name of the backup
  • <cPanelPassword> with your cPanel account password
mysqldump --opt -Q -u <cPanelUserName> -p<cPanelPassword> --all-databases > /home/<cPanelUserName>/<FILE_NAME_HOME_DIRECTORY_>`date +%d%m%y`.sql

When each time a cron jobs run, this will generate a .sql and append the day, month, and the year in the end of file.

To confirm your cPanel account didn’t build a backup for your database and increase your account’s disk space usage, Here, it is necessary to download copies of backups to your computer and delete it from your server.

Confirm Your Backups

It’s a good idea to login into your account and checks that these files are being created. That way, if you need to restore your database from a backup, you can download the file and restore your database from a backup. If you use cPanel, you can do this by logging into File Manager. Simply confirm that these files exist and check the timestamp of when the backup was created once you are logged in to File Manager.

Thanks for reading our articles.

Please follow our blog post to ensure to gain your knowledge day-to-day.

Leave a Comment