Difference between revisions of "Backups"

From WHMCS Documentation

(Created page with 'It is strongly recommended that you backup your WHMCS Database regularly to ensure you always have a copy of your data should a server or system failure occur. Backing up the da…')
 
 
(40 intermediate revisions by 7 users not shown)
Line 1: Line 1:
It is strongly recommended that you backup your WHMCS Database regularly to ensure you always have a copy of your data should a server or system failure occur. Backing up the database is a very simply task with the built in backup tool and can even be fully automated.
+
We strongly recommend that you back up your WHMCS database regularly, so that you always have a copy of your data if a server or system failure occurs. Backing up the database is a very simply task with the built-in backup tool, and you can automate it.
 +
 
 +
==Automated Database Backup==
 +
 
 +
WHMCS can automatically back up your database and upload it to a SFTP/FTP location or email it to a designated email address.
 +
 
 +
To enable automatic backups, go to '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings  > [[Database Backups]]''' or, prior to WHMCS 8.0, '''Setup > Database Backups'''.
  
 
==Manual Database Backup==
 
==Manual Database Backup==
To manually download a backup of the WHMCS database at any time:
 
  
#Login to your WHMCS Admin Area
+
You can manually download a backup of the WHMCS database at '''Utilities > System > [[Database Status]]'''.
#Go to '''Utilities > Database Status'''  
 
#Click the Download Full Database Backup button at the top of the page
 
#You should be prompted for a file to download. Save the file to your computer.  Depending on the database size, this may take a few moments.
 
#Once the download is complete you have now backed up your database.
 
  
==Automated Database Backup==
+
==Executing Backup Task Manually==
WHMCS can automatically email a database backup to a designated email address or upload it to a remote location via FTP on a daily basis as part of the automation cron:
+
 
 +
The backup options configured are executed once per day via the cron. However, the task can be executed manually to check the configured backup options are working or as a separate cron command configured to execute the backup task more often:
  
#Login to your WHMCS Admin Area
+
<div class="source-cli">
#Go to''' Setup > Database Backups'''
+
php -q cron.php do --DatabaseBackup
#To use the email backup facility simply enter an email address is the '''Daily Email Backups''' section.
+
</div>
#To use the remote FTP backup facility enter the FTP connection details in the '''Daily Remote FTP Backup''' section. In the 'FTP Destination' field enter the path relative to the login folder where you'd like the backups uploaded, this location must exist as WHMCS cannot create the directories itself.
+
For more information, refer to the [[Crons#Task_Options_for_skip_and_do|Cron documentation]],
  
 
==Configuration.php Backup==
 
==Configuration.php Backup==
  
The configuration.php file in the main whmcs directory contains the encryption hash value unique to your particular installation, it's used to encrypt sensitive data so should it be lost this data can no longer be decrypted. Therefore it is important for a backup of this file to be kept in a secure location in case re-installation is necessary.
+
The <tt>configuration.php</tt> file in the main <tt>whmcs</tt> directory. It contains the encryption hash value unique to your particular installation, which encrypts sensitive data. If you lose the encryption hash value, the system won't be able to decrypt your data. Because of this, it is important to keep a backup of this file in a secure location in case reinstallation is necessary.
 +
 
 +
==Limitations==
 +
 
 +
As a database grows, it becomes too big for a PHP script like the WHMCS cron job to handle, due to the amount of data in it exceeding various server limits, usually when the database exceeds 20 MB. The size prevents the system from completing an FTP or Email backup.
 +
 
 +
In this case, we recommend switching to the '''[[Database_Backups#cPanel_Backup|cPanel Backup]]''' option instead (if you installed WHMCS on a cPanel server). By off-loading the backup tasks from PHP to the cPanel system processes, it allows you to generate much larger backups without impacting performance of your website.
 +
 
 +
When switching to cPanel or external backups, you will need to ensure that you have disabled the FTP and Email Backup features in your WHMCS installation to prevent errors with the cron due to the large database size.
 +
 
 +
If you are not on a cPanel server, you can use an external tool such as '''mysqldump''' to export your database. More information can be found in the [https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html MySQL documentation].
 +
 
 +
==Optimise Tables==
 +
 
 +
In normal operation, MySQL® tables can generate overhead. You can optimise your databases to reduce this problem at '''Utilities > System > [[Database Status]]'''.
 +
 
 +
==Troubleshooting==
 +
 
 +
The most common reason for database backups to fail is that it has grown too large and the PHP process takes too long or uses too much memory and is killed before it can complete the backup process.
 +
 
 +
For more information, see [[Backups#Limitations|Limitations]].
 +
 
 +
===Onscreen Errors===
 +
 
 +
A number of errors may occur onscreen when you generate a manual database backup, or in '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > [[System Logs]]''' (or '''Utilities > Logs > Activity Log''' in WHMCS 7.x and earlier) when generating an automated database backup:
 +
 
 +
====Table 'xxx' doesn't exist when using LOCK TABLES====
 +
 
 +
This indicates that the named table <tt>xxx</tt> has crashed or is corrupted. Running a MySQL® repair operation will resolve this. You can repair tables via the '''MySQL Databases''' page within cPanel or using a tool such as phpMyAdmin.
 +
 
 +
====Database backup unavailable due to missing required zip extension====
 +
 
 +
This indicates that you need to [http://php.net/manual/en/class.ziparchive.php recompile PHP] after enabling the ZipArchive PHP class, which WHMCS requires to compress the backup.
 +
 
 +
====Database backup error 'Please provide a valid dump path'====
 +
 
 +
This indicates that WHMCS is unable to access the <tt>/tmp</tt> working directory during the backup generation process. Make sure that the <tt>[http://php.net/manual/en/ini.core.php#ini.open-basedir open_basedir]</tt> value is ''Off'' in your PHP configuration, and that the PHP <tt>/tmp</tt> directory is writeable and is not full.

Latest revision as of 20:39, 18 April 2022

We strongly recommend that you back up your WHMCS database regularly, so that you always have a copy of your data if a server or system failure occurs. Backing up the database is a very simply task with the built-in backup tool, and you can automate it.

Automated Database Backup

WHMCS can automatically back up your database and upload it to a SFTP/FTP location or email it to a designated email address.

To enable automatic backups, go to Configuration () > System Settings > Database Backups or, prior to WHMCS 8.0, Setup > Database Backups.

Manual Database Backup

You can manually download a backup of the WHMCS database at Utilities > System > Database Status.

Executing Backup Task Manually

The backup options configured are executed once per day via the cron. However, the task can be executed manually to check the configured backup options are working or as a separate cron command configured to execute the backup task more often:

php -q cron.php do --DatabaseBackup

For more information, refer to the Cron documentation,

Configuration.php Backup

The configuration.php file in the main whmcs directory. It contains the encryption hash value unique to your particular installation, which encrypts sensitive data. If you lose the encryption hash value, the system won't be able to decrypt your data. Because of this, it is important to keep a backup of this file in a secure location in case reinstallation is necessary.

Limitations

As a database grows, it becomes too big for a PHP script like the WHMCS cron job to handle, due to the amount of data in it exceeding various server limits, usually when the database exceeds 20 MB. The size prevents the system from completing an FTP or Email backup.

In this case, we recommend switching to the cPanel Backup option instead (if you installed WHMCS on a cPanel server). By off-loading the backup tasks from PHP to the cPanel system processes, it allows you to generate much larger backups without impacting performance of your website.

When switching to cPanel or external backups, you will need to ensure that you have disabled the FTP and Email Backup features in your WHMCS installation to prevent errors with the cron due to the large database size.

If you are not on a cPanel server, you can use an external tool such as mysqldump to export your database. More information can be found in the MySQL documentation.

Optimise Tables

In normal operation, MySQL® tables can generate overhead. You can optimise your databases to reduce this problem at Utilities > System > Database Status.

Troubleshooting

The most common reason for database backups to fail is that it has grown too large and the PHP process takes too long or uses too much memory and is killed before it can complete the backup process.

For more information, see Limitations.

Onscreen Errors

A number of errors may occur onscreen when you generate a manual database backup, or in Configuration () > System Logs (or Utilities > Logs > Activity Log in WHMCS 7.x and earlier) when generating an automated database backup:

Table 'xxx' doesn't exist when using LOCK TABLES

This indicates that the named table xxx has crashed or is corrupted. Running a MySQL® repair operation will resolve this. You can repair tables via the MySQL Databases page within cPanel or using a tool such as phpMyAdmin.

Database backup unavailable due to missing required zip extension

This indicates that you need to recompile PHP after enabling the ZipArchive PHP class, which WHMCS requires to compress the backup.

Database backup error 'Please provide a valid dump path'

This indicates that WHMCS is unable to access the /tmp working directory during the backup generation process. Make sure that the open_basedir value is Off in your PHP configuration, and that the PHP /tmp directory is writeable and is not full.