Hostwinds Tutorials

Search results for:


Table of Contents


How To Set Up a Cron Job to Backup Your Database
Confirm Your Backups

How to Backup MySQL Database using cronjob in cPanel

Tags: Backups 

How To Set Up a Cron Job to Backup Your Database
Confirm Your Backups

This guide is about creating a cron job in cPanel to make a backup of your databases. This article is intended for Hostwinds clients who use cPanel and can create a cron job through the cPanel interface. Hostwinds clients are encouraged to keep a working backup before performing any upgrades, site maintenance, or before making changes if the database needs to be restored.

How To Set Up a Cron Job to Backup Your Database

  1. Login into cPanel
  2. Navigate to the Advanced section and click on Cron Jobs
  1. Enter the email address for notifications
  2. Select a common setting from the drop-down menu, such as once per week
  3. Select a non-peak hour to run the cron job
  4. Enter the following into the command area:

Replace the following three items

  1. \ with your cPanel username
  2. \ with the name of the backup
  3. \ with your cPanel account password
mysqldump --opt -Q -up --all-databases > /home//<FILE_NAME_HOME_DIRECTORY_>`date +%d%m%y`.sql
  • Each time the cron job runs, this will create a .sql and append the day, month and year to the end of the file.

To ensure your account does not build backups of your databases and increase your account's disk space usage, it is important to download copies of these backups to your computer and remove them 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. Confirm that these files exist and check the timestamp of when the backup was created once you are logged in to File Manager.

If we can help you in any way, please submit a ticket or join us in a Live Chat anytime. We are available 24/7/365, and we are dedicated to our client's success; every client truly matters to us.

Written by Hostwinds Team  /  April 27, 2018