(Redirected from Automatic Backups)
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.
- 1 Automated Database Backup
- 2 Enabling Automatic Backups
- 3 SFTP/FTP Backup
- 4 cPanel Backup
- 5 Manual Database Backup
- 6 Configuration.php Backup
- 7 Limitations
- 8 Optimise Tables
- 9 Troubleshooting
Automated Database Backup
WHMCS can automatically backup your database and upload to a SFTP/FTP location and/or email it to a designated email address.
From WHMCS 7.3, it is also possible to request a full cPanel backup for a specific user as part of the automatic backup process.
Enabling Automatic Backups
All backup configuration is completed in Setup > Other > Database Backups.
The available options are SFTP/FTP backup, Email backup and full cPanel Account backup.
The SFTP/FTP and cPanel Backup options require a connection test being successful before activation. A connection test ensures the details are valid and the WHMCS installation can connect to the server. Any connection issue allows a resolution before a backup attempt occurs meaning less chance of a failed connection.
This backup will place the WHMCS generated zipped sql file on the specified remote server.
Checking the "Use Secure FTP/SFTP (Recommended)" box will ensure the backup upload is completed using an SFTP connection.
This value should be relative to the login folder for the FTP/SFTP account being used. No initial slash should be used, for example, if upon logging in using those FTP details the folder is /home/user/ and the backup should be in /home/user/backups, then enter backups/ as the FTP Destination. If the login folder is where the backup file is to be uploaded, leave this field empty.
The cPanel Backup option uses the Full Backup feature of WHM/cPanel's backup wizard.
- Home Directory — Select this option to save the backup file to the server.
- Remote FTP Server — Select this option to use FTP to store the backup file on a remote server.
- Remote FTP Server (Passive Mode Transfer) — Select this option to use passive FTP to store the backup file on a remote server.
- SCP — Select this option to use SCP to store the backup file on a remote server.
The System Cron will only request the start of a full backup. Completion, and relocation of the backup occurs within cPanel and will not be notified though WHMCS.
Manual Database Backup
To manually download a backup of the WHMCS database at any time:
- Login to your WHMCS Admin Area
- Go to Utilities > System > 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.
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.
As a DB grows, it becomes too big for a PHP script like the WHMCS cron to handle backing up due to the amount of data within it causing various server limits to be exceeded, usually around the 20MB mark. Unfortunately being big means that for a PHP script to loop through and save that data into temporary memory in order to generate an FTP or Email backup is not possible - either the memory limits or max execution time limits on the server will be reached and terminate the script.
In this case we recommend switching to the cPanel backup option instead (if WHMCS is installed on a cPanel server). By off-loading the backup tasks from PHP to the cPanel system processes, it allows much larger backups to be generated without impacting performance of your website.
In normal operation MySQL tables can generate overhead, put simply this is space assigned to the table that isn't being used but is still taking up disk space. MySQL has a function called optimise tables which can be used to reduce this. Usually this command is from from the server's command line or phpmyadmin, but it can also be run within WHMCS by clicking the Utilities > System > Database Status > Optimise Tables button.
A number of errors may occur on-screen when generated a manual database backup, or in the Utilities > Logs > Activity Log when generated an automated database backup. They are explained below:
Table 'xxx' doesn't exist when using LOCK TABLES
Indicates the named table 'xxx' is crashed or corrupted. Running a MySQL repair operation will resolve this. Tables can be repaired via the MySQL Databases page within cPanel or using a tool such as phpmyadmin.
This refers to the ZipArchive PHP class which is required by WHMCS to compress the backup. Please recompile PHP with support for this class: http://php.net/manual/en/class.ziparchive.php
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. Please ensure that the open_basedir value is set to Off in your PHP configuration, that the PHP /tmp directory is writeable and is not full.