Page tree
This documentation is for cPanel & WHM version 84 CURRENT builds.  The "RELEASE" version of our documentation can be found in the Version 82 Documentation space.


Skip to end of metadata
Go to start of metadata

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. You can use this script to back up and restore the following modules:

  • Apache — cPanel & WHM uses Apache to host websites.

    Notes:

    • 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.

    • 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 settings. You must use this script to perform these actions.

  • WHM (whmconf) — cPanel & WHM uses the whmconf service 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).
    • WHM's Basic WebHost Manager Setup interface (WHM >> Home >> Server Configuration >> Basic WebHost Manager Setup).

The /usr/local/cpanel/bin/cpconftool 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 script accepts the following options:

Note:

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, for example.


OptionDescriptionExample
--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.

--list-modules

The output will resemble the following example:

cpanel::easy::apache
cpanel::smtp::exim
cpanel::ssl::autossl
cpanel::system::backups
cpanel::security::cphulk
cpanel::system::greylist
cpanel::system::modsecurity
cpanel::system::mysql
cpanel::system::whmconf
cpanel::ui::themes
--query-module-infoList 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:

  1. Log in to the server as the root user via SSH. 
  2. Navigate to the /usr/local/cpanel directory.
  3. To list available configuration modules, run the following command:

    /usr/local/cpanel/bin/cpconftool --list-modules

    The script will display a list of available configuration modules. For example:

    cpanel::easy::apache
    cpanel::smtp::exim
    cpanel::ssl::autossl
    cpanel::system::backups
    cpanel::security::cphulk
    cpanel::system::greylist
    cpanel::system::modsecurity
    cpanel::system::mysql
    cpanel::system::whmconf
    cpanel::ui::themes
  4. 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:

    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

Important:

The Apache configurations may require additional steps. For more details, see the Apache module differences section below.

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 and config::to::restore represents the module to restore:

/usr/local/cpanel/bin/cpconftool --restore=/home/backup.tar.gz --modules=config::to::restore

When you restore a configuration module, the following actions occur:

  1. The script restores all of the configuration files. 

    Note:

    The script removes any configuration files on the destination server that did not exist the source server.

  2. The /usr/local/cpanel/bin/cpconftool script tests whether the configuration settings are valid.
  3. 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:

Restore Successful
---
cpanel::system::whmconf:
  post_restore:
    data: "<span class=\"b2\">Your changes have been saved.<br /><br /><span class=\"b2\">Restarting cPanel daemons...<span class=\"b2\">done.<br /><br /><span class=\"b2\">Updating your system to reflect any changes...<br /><pre>Processing post action for <span class=\"setting_label\">Thunderbird and Outlook autodiscover and autoconfig support (enables proxy subdomain and SRV record creation):\nThe master proxysubdomains setting changed state so we do not need to update the autodiscover domains.\nProcessing post action for <span class=\"setting_label\">Conserve memory:\nProcessing post action for <span class=\"setting_label\">Standardized Hooks - Debug Mode:\nProcessing post action for <span class=\"setting_label\">Include mailman in disk usage calculations:\nProcessing post action for <span class=\"setting_label\">Include databases in disk usage calculations:\nProcessing post action for <span class=\"setting_label\">Mail authentication via domain owner password:\nProcessing post action for <span class=\"setting_label\">Number of failed or deferred messages a domain may send before protections can be triggered:\nProcessing post action for <span class=\"setting_label\">Enable Email Archiving support:\nProcessing post action for <span class=\"setting_label\">Email delivery retry time:\nProcessing post action for <span class=\"setting_label\">Allow cPanel & WHM to determine the best value for your MySQL innodb_buffer_pool_size configuration?:\nProcessing post action for <span class=\"setting_label\">Allow cPanel & WHM to determine the best value for your MySQL max_allowed_packet configuration?:\nProcessing post action for <span class=\"setting_label\">Allow cPanel & WHM to determine the best value for your MySQL open_files_limit configuration?:\nProcessing post action for <span class=\"setting_label\">cPanel PHP max execution time:\nProcessing post action for <span class=\"setting_label\">cPanel PHP max POST size:\nProcessing post action for <span class=\"setting_label\">cPanel PHP max upload size:\nProcessing post action for <span class=\"setting_label\">cPanel PHP loader:\nProcessing post action for <span class=\"setting_label\">Allow users to relay mail if they use an IP address through which someone has validated an IMAP or POP3 login within the last hour (Pop-before-SMTP):\nProcessing post action for <span class=\"setting_label\">Proxy subdomains:\nCreating service domain DNS entries in background. This process can take several minutes to complete.\nProcessing post action for <span class=\"setting_label\">Require SSL:\nProcessing post action for <span class=\"setting_label\">Enable Analog stats:\nProcessing post action for <span class=\"setting_label\">Enable Awstats stats:\nProcessing post action for <span class=\"setting_label\">Enable BoxTrapper spam trap:\nProcessing post action for <span class=\"setting_label\">Enable Horde Webmail:\nProcessing post action for <span class=\"setting_label\">Enable Mailman mailing lists:\nmailman...(XID jcptbq) The \xE2\x80\x9Cmailman\xE2\x80\x9D service is disabled.\nWaiting for \xE2\x80\x9Cmailman\xE2\x80\x9D to stop \xE2\x80\xA6\xE2\x80\xA6\xE2\x80\xA6finished.<br />\n<br />\n...Done\nRestarting mailman\nConfiguration file passes test!  New configuration file was installed.\n\n\n\n/etc/exim.pl.local installed!\nSPF is disabled in exim or unavailable, enabling SPF for SpamAssassin\nRefreshing SMTP Mail protection.\nSMTP Mail protection has been disabled.  All users may make outbound smtp connections.\nDisabled scgi-bin since suexec is enabled or the webserver runs as the user\nDistilled successfully\nProcessing post action for <span class=\"setting_label\">Enable Apache SpamAssassin\xE2\x84\xA2 spam filter:\nProcessing post action for <span class=\"setting_label\">Enable Apache SpamAssassin\xE2\x84\xA2 Spam Box delivery for messages marked as spam (user configurable):\nProcessing post action for <span class=\"setting_label\">Enable Webalizer stats:\nProcessing post action for <span class=\"setting_label\">Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak):\nProcessing post action for <span class=\"setting_label\">Prefix &ldquo;mail.&rdquo; onto Mailman URLs:\nProcessing post action for <span class=\"setting_label\">Use pre-4.1-style MySQL<sup>&reg;</sup> passwords:\n</pre><span class=\"b2\">Done.</div>\n</body>\n</html>\n"
    status: 1
    statusmsg: Update WHMhostmgr Succeeded
  restore:
    data:
      warnings: []
    status: 1
    statusmsg: "Whostmgr::Config::Restore::System::WHMConf: ok"

Transfer configuration settings

Warning:

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:

  1. Perform the backup process for the configuration module on the source server.

  2. Copy the .tar.gz file from the previous step from the source server to the destination server.
  3. Perform the restoration process for the configuration module on the destination server.

Apache module differences

Important:

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 and restart Apache. For more information, run the following command:

/usr/local/cpanel/scripts/rebuildhttpdconf --help

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.confmodsec2.user.conf, or modsec2.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 the modsec2.user.conf configuration file includes.

    Warning:

    We strongly recommend that you do not manually extract these files.

Additional documentation