Backup and restore cPanel accounts is crucial for ensuring the safety of your website data and configurations. Using SSH (Secure Shell), this process becomes faster and more secure, especially when managing multiple accounts on a server. In this guide, we will take you through the step-by-step process of how to backup and restore cPanel accounts via SSH.
Table of Contents
Why Backup and Restore cPanel Accounts via SSH?
Using SSH to backup and restore cPanel accounts offers several benefits, including:
- Speed: It is much faster than using a web interface.
- Automation: You can automate the backup and restore process using scripts.
- Security: SSH ensures secure, encrypted communication.
- Full control: You have direct access to cPanel’s core functionalities and files.
Let’s dive into the steps required for backing up and restoring cPanel accounts.
Step 1: Access Your Server via SSH
Before you can backup or restore any cPanel accounts, you need to access your server using SSH. If you’re using a Windows machine, you can use an SSH client like PuTTY, while Linux and macOS users can use the terminal.

- Open your terminal (Linux/Mac) or PuTTY (Windows).
- Connect to your server by running the following command:
ssh root@your-server-ip
Replace root with your root user and your-server-ip with the IP address of your server. - Enter your root password when prompted.
Once connected, you’ll be able to run the commands necessary to backup and restore cPanel accounts.
Step 2: Backup a cPanel Account via SSH
To create a backup of a cPanel account, you can use the pkgacct command, which packages the entire account, including website files, databases, emails, and cPanel settings.
Command to Backup a cPanel Account
- Run the following command to create a full backup of a specific cPanel account:
/scripts/pkgacct username
Replace username with the actual username of the cPanel account you want to back up.


For example, if the cPanel account username is cpanelwebhosting, the command would be:
/scripts/pkgacct cpanelwebhosting
- The backup file will be saved in the /home directory by default and named something like cpmove-username.tar.gz.
Backup Location and Transfer
- To specify a different directory for the backup:
/scripts/pkgacct username /path/to/destination
Replace /path/to/destination with the directory where you want to save the backup file.
Step 3: Restore a cPanel Account via SSH
Restoring a cPanel account is just as simple. You will use the restorepkg command to restore a backup to the server.
Command to Restore a cPanel Account
- Make sure the backup file is in the /home directory of the server, or specify the correct path to the backup file.
- Run the following command to restore the cPanel account:
/scripts/restorepkg username
Replace username with the cPanel account username.

For example:
/scripts/restorepkg exampleuser
This command will extract the backup and restore the cPanel account, including all its data and settings, to the server.
Common Issues and Troubleshooting
Here are some common issues you might face while backing up and restoring cPanel accounts via SSH, along with possible solutions:
1. Permission Denied
If you receive a “Permission Denied” error, ensure that you have root or sudo privileges on the server.
2. Disk Space Issues
Backups can be large, so make sure that your server has enough disk space to store the backup files.
3. Corrupted Backup
If the backup file is corrupted, try running the pkgacct command again. Also, consider verifying the integrity of the backup by restoring it in a test environment before restoring it on a live server.
4. Incorrect Username
Make sure the username you are using for the backup or restore is correct.
Conclusion
Backing up and restoring cPanel accounts via SSH is a powerful and efficient way to manage your server’s data. Whether you’re handling one account or multiple, SSH offers speed, security, and flexibility. By following the steps outlined in this guide, you’ll be able to create and restore cPanel backups with ease. Additionally, automating the process using cron jobs can save you time and ensure that your data is always secure.
Regularly taking backups and knowing how to restore them is an essential practice for any webmaster or system administrator, as it ensures the safety and continuity of your online services.
