How to Create a Full cPanel Backup through SSH

In this tutorial, you’ll learn how to create a full cPanel backup via SSH.

  1. Access SSH:

  • You have to log in to your server’s command line using SSH as the ‘root’ user. Then, you can typically access SSH through a terminal program on your local computer or a web-based terminal provided by your web hosting provider.
  1. Initiate Backup:

  • As a user, you can use the following command to start the backup process:

/usr/local/cpanel/bin/backup

  • Note: If backups aren’t scheduled for that day, you might need to add the “–force” option to the command:

/usr/local/cpanel/bin/backup –force

  1. Optional: Specify Destination (for individual cPanel account backup)

In case, you want to take a backup for an individual cPanel account then follow these steps to get the output.

  • By default, the backup will be created in your current directory.
  • To specify a different location for the backup of a single cPanel account, use the /scripts/pkgacctcommand followed by the username and desired destination (optional):

/scripts/pkgacct username /path/to/desired/destination

  1. Backup Completion:

  • The backup process might take some time depending on the amount of data.
  • Once finished, you’ll see confirmation messages on your terminal.

Important Notes:

  • Remember to replace “username” with the actual cPanel username for individual account backups.
  • Ensure you have enough disk space to store the backup file.
  • It’s recommended to back up your data regularly and store the backups in a secure off-site location.

Check below the different Script options

This script accepts the following options:

Option Description Example
Username Required
The cPanel account username is useful to create a cpmove archive. You can pass on this option after any options, but before the DIRECTORY option.
Example

 

DIRECTORY This directory path is useful to store the archive. By default, the script uses the /home directory. You can pass this option after the USERNAME option. /usr/local/cpanel/backups
–allow-override Utilize the /var/cpanel/lib/Whostmgr/Pkgacct/pkgacct file to package the account, if it exists.

Note: You must pass on this option before any other options.

–allow-override
–mysql=VERSION The archive’s required minimum version of MySQL® –mysql=5.1.1
–roundcube=VERSION The archive’s required minimum version of Roundcube. –roundcube=3.0
–dbbackup=TYPE
  • The type of database backup to perform:
    all: The script help to take backs up of all the database information. Hence, this is the default option.
    schema: This script help to take backs up of database schemas. Only use this option to monitor a database’s users if you back up your databases via a unique method.
    name: This script is responsible for taking only back up of databases names. MySQL databases transfer as placeholders consisting a CREATE TABLE statement. PostgreSQL® databases transfer as blank .tar placeholder files.

 

–dbbackup=all
–dbbackup_mysql=TYPE An override of the –dbbackup option for MySQL only. This option comes with same values as the –dbbackup option.

Note: If you pass **both** this option and the `–dbbackup` option, the system applies the `–dbbackup_mysql` option to MySQL and the `–dbbackup` option to PostgreSQL.

 

This alternative does not affect PostgreSQL backups.

–dbbackup_mysql=all
–get_version Display the version of the pkgacct script.

 

–get_version
–use_backups

 

It helps to use the account’s last known successful backup as a template when the script creates the archive. Also, this option is useful for speeding up the backup process. –use_backups
–incremental This allows us to update the destination file with any new content since the previous backup. This option also helps to eliminate the content that no longer exists on the account. If destination file doesn’t exist, the script develops a new file in that location

 

Note: This option will pass the –nocompress option to develop an uncompressed archive

–incremental
–split Develops the archive in smaller data files. This option decreases the overall load on the system and makes it easier to transfer the files. The system develops these files in the cpmove-USERNAME.tar.gz.part00001 format, where USERNAME is the user’s account and part00001 is the file’s incremental ID.

 

–split
–nocompress Do not compress the archive. –nocompress
-userbackup This helps the user to use the archive as a backup file for the account ((for example, backup-3.18.2020_09-16-55_USERNAME). The system develops the file in the /home directory. This file is compatible with WHM’s Transfer or Restore a cPanel Account interface (WHM » Home » Transfers » Transfer or Restore a cPanel Account).

 

Important:

The system allows to creates two ASCII files for internal use in the /home/USERNAME directory, where USERNAME is the cPanel account name. You must remove these ASCII files after the system develops them. To develops a backup file without the ASCII files, use UAPI’s fullback to homedir function.

–userbackup
–backup=FILEPATH Use the archive as a backup for the account at the given file path. This option develops the username.tar.gz file, where username mean the account’s username. –backup=/usr/local/cpanel/backups
–serialized_output Inscribe each line of the script’s output in JSON format to allow the live_tail_log.cgi script to stream it. –serialized_output
–skipacctdb Eliminate the account’s MySQL and PostgreSQL databases from the archive. -skipacctdb
–skipapitokens Eliminate the account’s API tokens from the archive. –skipapitokens
–skipapitokens Eliminate the account’s external authentication credentials from the archive. –skipauthnlinks
–skipbwdata Eliminate the account’s bandwidth data from the archive. –skipbwdata
–skipcron Eliminate the account’s cron data from the archive. –skipcron
–skipdnszones Eliminate the account’s DNS zone file information from the archive. –skipdnszones
–skipdomains Eliminate the account’s subdomains, parked domains (aliases), and addon domains from the archive. –skipdomains
–skipftpusers Eliminate the account’s FTP user accounts from the archive. –skipftpusers
–skiphomedir Eliminate the account’s /home directory from the archive. Use this option if you will save or transfer the /home directory with another method, like rsync command.

 

–skiphomedir
–skipintegrationlinks
Eliminate the account’s integration links from the archive –skipintegrationlinks
–skiplinkednodes Eliminate the account’s server node linkages from the archive. –skiplinkednodes
–skiplocale Eliminate the account’s locale information or customized locale from the archive -skiplocale
–skiplogs Eliminate the account’s log files from the archive –skiplogs
–skipmail Eliminate the account’s mail directory from the archive. –skipmail
–skipmailconfig Eliminate the account’s mail configuration information from the archive. –skipmailconfig
–skipmailman Eliminate the account’s Mailman mailing lists from the archive. –skipmailman
–skipmysql Eliminate the account’s MySQL databases, database users, and database grants from the archive. –skipmysql
–skippasswd Eliminate the account’s password from the archive. –skippasswd
–skippgsql Eliminate the account’s PostgreSQL databases, database users, and database grants from the archive. –skippgsql
–skippublichtml Eliminate the account’s /public_html directory. –skippublichtml
–skipquota Eliminate the account’s disk quota limits from the archive. –skipquota
–skipresellerconfig Eliminate the account’s reseller privileges from the archive. –skipresellerconfig
–skipssl Eliminate the server’s SSL certificates and files in the Apache® configuration. This option does not exclude the SSL files in the account’s /home directory. –skipssl
–skipuserdata Eliminate the account’s subaccount information. You create these accounts in cPanel’s User Manager interface (cPanel » Home » Preferences » User Manager). –skipuserdata
–help Display a brief help message. –help
–man Display the script’s full documentation. –man

Leave a Reply