Tudásbázis

How To Set Up A Cron Job To Do A MySQL Database Backup

In order to do a backup of your database through a cron job, you can set this up in cPanel. Navigate to cPanel >> Advanced >> Cron Jobs.



You can select the backup frequency that you need then enter the command to backup. Here is a sample cron job:

 /usr/bin/mysqldump -u DBUSERNAME -p PASSWORD dbname > /home/CPANELUSERNAME/FILE_NAME_HOME_DIRECTORY$date.sql

This cron job will do a backup of the database based on your selected Schedule. Then it will save the backup with the current date appended to the file name.

A few notes:

-uDBUSERNAME – there should be no space between -u and DBUSERNAME, DBUSERNAME is the username of the database you are trying to backup.

-pPASSWORD – there should be no space between -p and PASSWORD, PASSWORD is the password of the database user.

dbname – this is the name of your database.

/home/CPANEL_USERNAME/BACKUP_NAME$date.sql – cpanelusername is your username to log into cpanel, and this will save the backup in your home directory (you can change it to whatever directory you want). You can call the backup whatever you wish but adding $date at the end will append the date to that backup.

This is not something that Jupiter Zone helps to customize, but if you have questions about how cron works or your MySQL databases, please contact our Support Team.

  • 1 A felhasználók hasznosnak találták ezt

Hasznosnak találta ezt a választ?

Kapcsolódó cikkek

cPanel: Adding domains to your hosting plan

Jupiter Zone allows you to host multiple domains on the same hosting plan. Once your hosting plan...

Automatically Backup your website in cPanel with a script

Basically we need to set up a script and run that in “Cron” which is a linux tool that allows...

How To Use SPF To Protect Your Domain From Spoofing

What Is Sender Policy Framework (SPF) ? SPF is an email authentication standard. A domain...