How to create cPanel backup from command line

blog background image

This is a articale all about cpanel backup from command line. Let's start...

To create a backup of a cPanel account from the command line, you can use the /usr/local/cpanel/scripts/pkgacct script. This script is included with cPanel and can be used to create a full backup of an account, including all files, databases, and email.

Here is an example of how you can use the pkgacct script to create a backup of an account:

/usr/local/cpanel/scripts/pkgacct username

Replace "username" with the actual username of the account you want to create a backup for.

This will create a tar.gz file in the current directory that contains the full backup of the account. You can specify a different location for the backup file by using the --dest option, like this:

/usr/local/cpanel/scripts/pkgacct username --dest /path/to/backup/directory

How to take cpanel backup without home directory 

You can also use the --skiphomedir option to exclude the home directory from the backup, like this:

/usr/local/cpanel/scripts/pkgacct username --skiphomedir



How to create cPanel backup without mail. 

To create a backup of a cPanel account from the command line without including the email, you can use the /usr/local/cpanel/scripts/pkgacct script with the --skipmail option. This script is included with cPanel and can be used to create a full backup of an account, excluding the email.

Here is an example of how you can use the pkgacct script to create a backup of an account without the email:

/usr/local/cpanel/scripts/pkgacct username --skipmail

Replace "username" with the actual username of the account you want to create a backup for.

This will create a tar.gz file in the current directory that contains the full backup of the account, excluding the email. You can specify a different location for the backup file by using the --dest option, like this:

/usr/local/cpanel/scripts/pkgacct username --skipmail --dest /path/to/backup/directory

How to take all cpanel account backup using commandline

To create a backup of all cPanel accounts on a server from the command line, you can use the /scripts/pkgacct script in a loop. This script is included with cPanel and can be used to create a full backup of an account, including all files, databases, and email.

Here is an example of how you can use the pkgacct script to create a backup of all accounts on a server:

for i in $(whmapi1 listaccts | grep user | cut -d: -f2); do /scripts/pkgacct $i done

This will create a tar.gz file in the current directory for each account on the server, containing the full backup of the account. You can specify a different location for the backup files by using the --dest option in the loop, like this:

for i in $(whmapi1 listaccts | grep user | cut -d: -f2); do /scripts/pkgacct $i --dest /path/to/backup/directory done

To run a backup manually, log in to the command line via SSH as the root user and run the following command:

/usr/local/cpanel/bin/backup

Restoring a cPanel Backup via SSH

To restore a previously created backup of your cPanel account, just follow these steps:

  1. First, if you haven’t already, log in to SSH as the Root user.
  2. Navigate to the directory containing your backup file. *Note: In order to restore your data, you must be in the correct directory.
  3. Next, to restore your cPanel backup, enter the following command into the command line:
/scripts/restorepkg username

And there you have it!

Related Blog Post

Create, collaborate, and turn your ideas into incredible products with the definitive platform for digital design.

How to create cPanel backup from command line

12 December 2022

How to create cPanel backup from command line

This article explains how you can create cPanel backup from the command line, using your own username and password.

Read More
How to install Webuzo Panel on linux Server

12 December 2022

How to install Webuzo Panel on linux Server

Webuzo is a popular alternative to cPanel, a widely used web hosting control panel developed by cPanel, Inc.

Read More
What are NFT Domains?

02 February 2022

What are NFT Domains?

NFT domains are new web extensions that are deployed using ERC 721 and Polygon Network, except .zil which uses Zilliqa.

Read More
How to Delete a MySQL® Database

01 January 2022

How to Delete a MySQL® Database

This document describes how to manually delete a MySQL® database from a cPanel & WHM server. This is useful if, for exa

Read More
How to get Transfer Authorization Code from GoDaddy

11 November 2021

How to get Transfer Authorization Code from GoDaddy

To transfer your domain with us then must need EPP Code.

Read More

Got a question!

Contact us at