Automate MySQL Database Backup via Cronjob: Difference between revisions

From Acenet Knowledgebase
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Automating a MySQL Database backup in cPanel is a two step process.
Automating a MySQL Database backup in cPanel is a two step process.


{{warning|You will need to know your Database Username and Database Password in order to configure the backup.}}
==Create the cron entry in cPanel==
{{note|You will need to know your Database Username and Database Password in order to configure the backup.}}


==Create the cron entry in cPanel==
1) Log into your cPanel
 
2) Go to Advanced -> Cron Jobs


3) Enter the email you wish to email the results of the cron job to.


4) Scroll down a bit, and either select a common setting (Once a day, once a week, etc) from the drop down. or enter a custom entry for days, weeks, months, etc.


Log into your cPanel
5) For the command to run, enter the following:


<syntaxhighlight lang="bash">
date=`date -I`; /usr/bin/mysqldump -uDBUSERNAME -pPASSWORD dbname > /home/CPANELUSERNAME/FILE_NAME_HOME_DIRECTORY$date.sql
</syntaxhighlight>


==Configure the Log rotation==
==Configure the Log rotation==

Revision as of 10:57, 6 June 2018

Automating a MySQL Database backup in cPanel is a two step process.

Create the cron entry in cPanel

You will need to know your Database Username and Database Password in order to configure the backup.

1) Log into your cPanel

2) Go to Advanced -> Cron Jobs

3) Enter the email you wish to email the results of the cron job to.

4) Scroll down a bit, and either select a common setting (Once a day, once a week, etc) from the drop down. or enter a custom entry for days, weeks, months, etc.

5) For the command to run, enter the following:

<syntaxhighlight lang="bash"> date=`date -I`; /usr/bin/mysqldump -uDBUSERNAME -pPASSWORD dbname > /home/CPANELUSERNAME/FILE_NAME_HOME_DIRECTORY$date.sql </syntaxhighlight>

Configure the Log rotation