Base de Conhecimento
The cpconftool Script Imprimir este Artigo
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 thewhmconf
configuration 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 --option
Options
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
--backup
or the--prerestore_backup
option.
--restore=/home/whm-config-backup-all-1.1-1411229033.tar.gz --modules=cpanel::smtp::exim
-
--list-modules
— List the available modules on your server.Note:You do not need to include the
--modules
option.1 2 3 4 5 6 7 8 9 10
cpanel::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
--backup
or--restore
options.--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_backup
option 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
root
user via SSH. - Navigate to the
/usr/local/cpanel
directory. - To list available configuration modules, run the following command:
/usr/local/cpanel/bin/cpconftool --list-modules
1 2 3 4 5 6 7 8 9 10
cpanel::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::backup
represents the configuration module name:/usr/local/cpanel/bin/cpconftool --backup --modules=configuration::to::backup
The script will display a confirmation message that resembles the following example:
1 2
Backup Successful /home/whm-config-backup-1562881772.tar.gz
Note:The script will generate a unique backup filename. In this example, the script generated the backup as the
whm-config-backup-1562881772.tar.gz
file.
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_backup
When 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/cpconftool
script tests whether the configuration settings are valid. - The
/usr/local/cpanel/bin/cpconftool
script runs the/usr/local/cpanel/scripts/buildeximconf
script.- 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.gz
file 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::apache
The script performs the following tasks:
- The script moves the
/var/cpanel/secdatadir
file to the same location on the destination server. - The script moves the
/var/cpanel/modsec_cpanel_conf_datastore
file 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.conf
files. Any differences in Apache configurations could cause Apache to fail to restart. - The script modifies the ModSecurity settings in the current
modsec2.*.conf
files but does not replace them. - If the user has control of the
modsec2.user.conf
file, the script archives this file. The script also archives any file themodsec2.user.conf
configuration file includes.Warning:We strongly recommend that you do not manually extract these files.
Esta resposta lhe foi útil?
Artigos Relacionados
Overview: The cPanel & WHM installation process adds important scripts to your server’s...
Overview: You can use the /usr/local/cpanel/bin/dbmaptool script to grant ownership of databases...
Overview: This script allows you to manage the task queue system. The task queue system allows...
Overview: The /usr/local/cpanel/scripts/auto-adjust-mysql-limits script updates MySQL®...
Overview: The /usr/local/cpanel/bin/autossl_check script allows you to manually check the SSL...