/usr/local/cpanel/bin/cpconftool script backs up, restores, and transfers server configurations. This is useful, for example, when you migrate your cPanel & WHM accounts to a new server.
You can use this script to back up, restore, and transfer the following configurations:
Apache® — cPanel & WHM uses the Apache configuration to host websites.
- The Apache configuration also contains the system's ModSecurity™ configuration. Apache uses ModSecurity to provide intrusion detection and prevention on your web server.
- For more information about Apache backups, restoration, and transfers, read the More about Apache configurations section below.
Backups — cPanel & WHM uses the backups configuration as the system's primary back up and restore tool.
The backup configuration does not include legacy backup configurations.
- cPanel themes — cPanel & WHM uses the cPanel theme configuration in order to generate the cPanel and WHM interfaces.
Exim — cPanel & WHM uses Exim as the system's main mail transfer agent.
MySQL® — cPanel & WHM uses the MySQL configuration as the system's primary operations tool.
WHM's Transfer Tool interface (WHM >> Home >> Transfers >> Transfer Tool) does not allow you to back up, restore, or transfer MySQL configurations. You must use this script to perform these actions.
- WHM (
whmconf) — cPanel & WHM uses the
whmconfconfiguration to back up and restore WHM's common non-user-specific settings (for example, the settings from WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings) and WHM's Basic WebHost Manager Setup interface (WHM >> Home >> Server Configuration >> Basic WebHost Manager Setup)).
To use this script, run the following command as the
Restore a backup file. For more information, read the Restore a configuration section below.
Make certain that you specify the backup file's full path with this argument.
Generate a backup file. For more information, read the Back up a configuration section below.
|List the available modules on your server.|
The output will resemble the following example:
A comma-separated list of the modules to restore or back up.
You can pass this argument with the
Back up a configuration
To back up a configuration, perform the following steps:
- Log in to the server as the
rootuser via SSH.
- Navigate to the
To list available configurations, run the following command:
The system will display a list of available configurations. For example:
Run the following command to back up the configuration, where
configuration::to::backuprepresents the configuration name:
The system will display a confirmation message that resembles the following example:
The system will generate a unique backup filename. In this example, the system generated the backup as the
Configuration backup contents
When you back up a configuration, the system backs up the following files for each type of configuration:
Each file that this section lists will only exist when the configuration requires it.
Restore a configuration
When you restore an EasyApache 4 configuration backup with the
/usr/local/cpanel/bin/cpconftool script, it removes Apache's default include files. If Apache fails to start, run the
/usr/local/cpanel/scripts/rebuildhttpdconf script and restart Apache.
/home/backup.tar.gzrepresents the full path to the desired backup file and
config::to::restorerepresents the configuration to restore:
--prerestore_backupparameter is optional and causes the system to restore the original version of the file.
--prerestore_backupparameter is always active for Apache restorations and allows you to troubleshoot your system if an Apache configuration fails to restore.
The system restores all of the configuration files.
If one of the configuration files exists on the destination server but does not exist on the origin server, the system removes that file.
/usr/local/cpanel/bin/cpconftoolscript tests whether the configuration is valid.
/usr/local/cpanel/bin/cpconftoolscript runs the
- If the test fails, the system reverts the changes.
- If the test succeeds, the system restarts the configuration.
The restoration process returns output that resembles the following example:
Transfer a configuration
To transfer a configuration, perform the following steps:
Perform the backup process for the desired configuration on the origin server.
- Copy the
.tar.gzfile that the backup process creates from the origin server to the destination server.
- Perform the restoration process for the desired configuration on the destination server.
More about Apache configurations
When you back up and restore an Apache server, ModSecurity performs the following tasks for you:
- The system moves the
/var/cpanel/secdatadirfile to the same location on the destination server.
- The system moves the
/var/cpanel/modsec_cpanel_conf_datastorefile to the same location on the destination server.
- The system determines the ModSecurity Vendors configurations on your server, along with the inactive or active rules set on your system, and moves them to the destination server.
- The system determines the ModSecurity configurations on your server and then moves them to the destination server.
cPanel & WHM does not perform the following tasks for you:
- The system does not move the
modsec2.cpanel.conffiles. The system does not move these files due to the differences in the Apache configurations, which may cause Apache to fail to restart.
- When the system moves the ModSecurity configurations, it modifies these configurations in the current
modsec2.*.conffiles, but does not replace them.
If the user possess control of the
modsec2.user.confconfigurations, the system archives this file and any file the
We strongly recommend that you do not manually extract these files.