Child pages
  • The restorepkg Script
This documentation is for cPanel & WHM version 74 CURRENT builds.  The "RELEASE" version of our documentation can be found in the Version 72 Documentation space.

Skip to end of metadata
Go to start of metadata

Overview

You can use the /usr/local/cpanel/scripts/restorepkg script to restore a cPanel account from a backup file. 

Note:

You can also restore a cPanel account from a backup file in WHM's Restore a Full Backup cpmove File interface (WHM >> Home >> Backup >> Restore a Full Backup/cpmove File).

The /usr/local/cpanel/scripts/restorepkg script

To use the /usr/local/cpanel/scripts/restorepkg script, run the following command as the root user:

/usr/local/cpanel/scripts/restorepkg [arguments] [input] [filename]

Arguments

You can use the following arguments with the /usr/local/cpanel/scripts/restorepkg script:

ArgumentDescriptionInput valuesExample
--force

Restore the account regardless of any errors or warnings. When the system restores the account, any existing data remains intact on the server.

Note:

If the account already exists on the server, this option operates similarly to the --skipaccount option.

None.
--force
--allow_resellerRestore reseller privileges.None.--allow_reseller
--ip

Restore the account to a certain IP address.

Notes:

  • If an IP address is not available, the script uses the next available IP address in the IP address pool.
  • If no addresses are available, the script uses the server's shared IP address. 
  • y — Use the next available IP address in the IP address pool to restore the account.

  • n — Use the shared IP address to restore the account.
  • A valid IP address — Use this IP address to restore the account.

--ip=192.0.2.169
--newuser

Change the restored account's username.

Notes:

  • All of the account's database users will keep their current username except for the user that matches the cPanel account.
  • To change the name of a database or database user after you restore the account, use WHM's Manage Databases interface (WHM >> Home >> SQL Services >> Manage Databases) and WHM's Manage Database Users interface (WHM >> Home >> SQL Services >> Manage Database Users).
  • You cannot use this option with the --skipaccount option.

A valid cPanel username.

Notes:

  • The new account name cannot already exist on the server.
  • The username must contain 16 characters or fewer, and the first eight characters must be unique on the server.
--newuser=username
--skipaccount

Restore a package for an existing account with the same username as another existing account.

Note:

You cannot use this option with the --newuser option.

None.--skipaccount
--restricted

Run the restoration process with the Restricted Restore feature.

The Restricted Restore feature performs additional security checks on the backup file in order to mitigate the risk of transfers from unfamiliar sources. If a component of the backup file contains an issue (for example, a compromised MySQL® grant table or a symbolic link attack), the system does not restore that portion of the backup and adds a warning to the log file.

Note:

If you do not use this option, the script performs an unrestricted restore.

Warnings:

  • The Restricted Restore feature is EXPERIMENTAL. Do not consider it as an effective security control at this time. The behavior of this feature may change in a future release of cPanel & WHM. Exercise extreme caution when you use this feature.
  • If you do not trust the source of the account backup with root access to your server, use the Restricted Restore feature to protect your server.
  • To use the Restricted Restore feature to restore an account that owns PostgreSQL® databases, the target server must use PostgreSQL version 8.4 or newer.
  • The Restricted Restore feature only allows restored accounts to use the noshell or jailshell options. If the restored account uses another shell, the system will set the account to use the noshell option. For more information, read our VirtFS - Jailed Shell documentation.
None.--restricted
--disable

Disable specific modules during the account restoration process.

Warning:

We strongly recommend that only advanced users apply this option. If you incorrectly configure this option, the cPanel account may restore in a broken state.

A valid module name. (For example, MailRouting or SSL).

Notes:

  • Use a comma-separated list to specify multiple values.
  • For a list of possible values, run the --help option.
  • Module names are case-sensitive.

--disable=MailRouting,SSL

Files

The backup filename must use one of the following formats:

  • cpmove-{USER}
  • cpmove-{USER}.tar
  • cpmove-{USER}.tar.gz
  • {USER}.tar
  • {USER}.tar.gz
  • backup-{BACKUP-DATE_TIME}_{USER}.tar
  • backup-{BACKUP-DATE_TIME}_{USER}.tar.gz

The restore package script searches for the archive in the following locations:

  • /home
  • /home2
  • /home3
  • /root
  • /usr
  • /usr/home
  • /web

The script attempts to restore the account on the shared IP address with the following steps:

  1. Adds the package to the AccountLocal queue.
  2. Starts the restoration process.
  3. Uses the tail command to output the log file's contents after the restoration process begins.

Example

For example, the following command uses the unrestricted restore method to restore the cpmove-testaccount.tar.gz file to the 192.0.2.169 IP address:

/usr/local/cpanel/scripts/restorepkg --ip=192.0.2.169 cpmove-testaccount.tar.gz

Additional documentation