The cpconftool Script
Valid for versions 84 through the latest version
Version:
84
Last modified: 2020 December 2
Overview
Use the /usr/local/cpanel/bin/cpconftool script to back up and restore configuration settings. The script groups the configuration settings for different services into modules.
Modules
You can use this script to back up and restore the following modules:
-
Apache® — cPanel & WHM uses Apache to host websites.
Note:- The Apache module also modifies the servers’ ModSecurity® settings. Apache uses ModSecurity to provide intrusion detection and prevention on your web server.
- The Apache backup, restoration, and transfer processes differ from other modules. For more information, read the Apache Module Differences section below.
-
AutoSSL — The AutoSSL feature automatically issues free, Domain-Validated SSL certificates to users’ domains.
Note:This module does not modify the SSL Provider. To update your SSL provider, use WHM’s Manage AutoSSL interface (WHM » Home » SSL/TLS » Manage AutoSSL).
-
Backups — cPanel & WHM uses backups to copy or archive data. You can use this data to recover to a previous state.
Note:The backup module does not include legacy backup settings. -
cPanel themes — cPanel & WHM uses cPanel themes to generate the cPanel and the WHM interfaces.
-
cPHulk — The cPHulk service helps to protect your server against brute force attacks.
Note:- The script does not copy history reports.
- The script appends whitelist- and blacklist-management configuration settings. It does not replace these configuration settings.
-
Exim — cPanel & WHM uses Exim as the server’s main mail transfer agent.
-
GreyListing — The Greylisting feature defends email users against spam.
-
ModSecurity — This open-source web application firewall helps to detect and prevent intrusion. For more information, read our ModSecurity® documentation.
-
MySQL® — cPanel & WHM uses MySQL as the server’s database management.
Note: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 thewhmconfconfiguration to back up and restore WHM’s common settings that aren’t user-specific. 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).
Run the script
To use this script, run the following command as the root user:
/usr/local/cpanel/bin/cpconftool --optionOptions
The /usr/local/cpanel/bin/cpconftool --option script accepts the following options:
You can rename a backup file. The --restore and --prerestore_backup options do not rely on the file’s name. You could include modules in the filename.
-
--modules— (Required) A comma-separated list of the modules to restore or back up.Note:The Apache module also contains some ModSecurity settings. Use the ModSecurity module to affect only the ModSecurity settings.
--modules=cpanel::smtp::exim,cpanel::system::mysql -
--backup— Generate a backup file. For more information, read the Back up a configuration module section below.--backup --modules=cpanel::smtp::exim -
--restore— Restore from a backup file. For more information, read the Restore configuration settings section below.Important:- Make certain that you specify the full path to the backup file.
- We strongly recommend that you create a backup before you restore a module. Use either the
--backupor the--prerestore_backupoption.
--restore=/home/whm-config-backup-all-1.1-1411229033.tar.gz --modules=cpanel::smtp::exim -
--list-modules— List the available modules on your server.The output will resemble the following example:Note:You do not need to include the
--modulesoption.1 2 3 4 5 6 7 8 9 10cpanel::easy::apache cpanel::smtp::exim cpanel::system::autossloptions cpanel::system::backups cpanel::system::greylist cpanel::system::hulk cpanel::system::modsecurity cpanel::system::mysql cpanel::system::whmconf cpanel::ui::themes -
--query-module-info— List information about the version of the module.--query-module-info --modules=cpanel::smtp::exim -
--verbose— Display details about the operation that the script performs.Note:You can only pass this option with the
--backupor--restoreoptions.--backup --modules=cpanel::smtp::exim --verbose -
--prerestore_backup— Restore the original version of the file. The script creates a backup before it restores the module.Note:The
--prerestore_backupoption is always active for Apache restorations.--restore=/home/whm-config-backup-all-1.1-1411229033.tar.gz --modules=cpanel::smtp::exim --prerestore_backup
Back up a configuration module
To back up a configuration module, perform the following steps:
-
Log in to the server as the
rootuser via SSH. -
Navigate to the
/usr/local/cpaneldirectory. -
To list available configuration modules, run the following command:
The script will display a list of available configuration modules. For example:/usr/local/cpanel/bin/cpconftool --list-modules1 2 3 4 5 6 7 8 9 10cpanel::easy::apache cpanel::smtp::exim cpanel::system::autossloptions cpanel::system::backups cpanel::system::greylist cpanel::system::hulk cpanel::system::modsecurity cpanel::system::mysql cpanel::system::whmconf cpanel::ui::themes -
To back up the configuration module, run the following command. In the following example,
configuration::to::backuprepresents the configuration module name:/usr/local/cpanel/bin/cpconftool --backup --modules=configuration::to::backupThe script will display a confirmation message that resembles the following example:
1 2Backup Successful /home/whm-config-backup-1562881772.tar.gzNote:The script will generate a unique backup filename. In this example, the script generated the backup as the
whm-config-backup-1562881772.tar.gzfile.
Configuration backup contents
When you back up a configuration, the system uses the settings contained in certain files for each module. You can list the files that your server uses for a particular module. For example, to list the files for the Exim module, run the following command:
/usr/local/cpanel/bin/cpconftool --backup --modules=cpanel::smtp::exim --verboseYou can run this command for any module. You will receive output similar to the following example:
|
|
Restore configuration settings
To restore a configuration from a backup file, run the following command, where /home/backup.tar.gz represents the full path to the desired backup file and config::to::restore represents the configuration to restore:
/usr/local/cpanel/bin/cpconftool --restore=/home/backup.tar.gz --modules=config::to::restore --prerestore_backupWhen you restore a configuration module, the following actions occur:
- The system restores all of the configuration files.
Note:The script removes any configuration files on the destination server that did not exist the source server.
- The
/usr/local/cpanel/bin/cpconftoolscript tests whether the configuration settings are valid. - The
/usr/local/cpanel/bin/cpconftoolscript runs the/usr/local/cpanel/scripts/buildeximconfscript.
- If the test fails, the script reverts the changes.
- If the test succeeds, the script restarts the service.
The restoration process returns output that resembles the following example:
|
|
Transfer configuration settings
If you use this script to transfer configuration settings, you may encounter undesired behavior. Instead, we strongly recommend that you use WHM’s Transfer Tool interface (WHM » Home » Transfers » Transfer Tool).
To transfer configuration settings, perform the following steps:
- Perform the backup process for the configuration module on the source server.
- Copy the
.tar.gzfile from the previous step from the source server to the destination server. - Perform the restoration process for the configuration module on the destination server.
Apache module differences
When you restore the Apache module, the /usr/local/cpanel/bin/cpconftool script removes Apache’s default include files. If Apache fails to start, run the /usr/local/cpanel/scripts/rebuildhttpdconf script with the --help flag and restart Apache.
To restore configuration settings from a backup file, run the following command. In the following example, /home/backup.tar.gz represents the full path to the desired backup file:
/usr/local/cpanel/bin/cpconftool --restore=/home/backup.tar.gz --modules=cpanel::easy::apacheThe script performs the following tasks:
- The script moves the
/var/cpanel/secdatadirfile to the same location on the destination server. - The script moves the
/var/cpanel/modsec_cpanel_conf_datastorefile to the same location on the destination server. - The script determines the ModSecurity® Vendors configuration settings on your server.
- The script then determines the active or inactive rules that you set on your script.
- The script moves the ModSecurity configuration settings to the destination server.
The script does not perform the following tasks:
- The script does not move the
modsec2.conf,modsec2.user.conf, ormodsec2.cpanel.conffiles. Any differences in Apache configurations could cause Apache to fail to restart. - The script modifies the ModSecurity settings in the current
modsec2.*.conffiles but does not replace them. - If the user has control of the
modsec2.user.conffile, the script archives this file. The script also archives any file themodsec2.user.confconfiguration file includes.Warning:We strongly recommend that you do not manually extract these files.