Restore cPanel backup via command line – Quick and Easy way

Table of Contents

Restoring backup can be demanding, especially when you don’t have a control panel.

Again, unsupported backup format requires you to restore cPanel backup via command line. It involve steps like moving website content, database,  mail accounts, etc.

Often, this manual backup restore create unexpected errors too.

That’s why, at 1 onlyhost, we often get requests from our customers to restore cPanel backup as part of our Server Migration Services.

Today, we’ll see how our Migration Engineers restore cPanel backup via command line and fix the related errors.

 

The need for restoring cPanel backup via command line

As the first step, let’s check on the typical scenarios that requires cPanel backup restore from command prompt.

From our experience in managing cPanel servers, the need for manual restore pops up in cases like:

  • Destination server panel do not support cPanel backup format
  • Lack of control panel on the new server
  • Migration between unsupported servers

In such scenario, the best option that our Migration Experts suggest would be migration from SSH command prompt. This requires root access on the server.

Additionally, the restore of cPanel backup via command line can save time and effort. Also, the entire migration process will not be affected by any temporary connectivity issues in the computer connect to server.

We’ll now take a look on how we actually do the restore of cPanel backup.

 

How we restore cPanel Account Backup via SSH

1. Firstly, we generate and transfer the cPanel backup to another server via the following commands.

scripts/pkgacct username
scp /home/cpmove-user.tar.gz root@x.x.x.x:/home

2. Once the backup is transferred to another server. We log into the server as a root user. We find a full backup file in home directory.

For example,

/home/cpmove-user.tar.gz

3. We extract the file there and it brings all data from the old cPanel account to the new server.

5. Next, we find the website contents, homedir from the list and move the files to the corresponding website document root.

6. Then we locate the mysql files, database.sql and restore that file to the database using the below command.

mysql -u username -p databasename < database.sql

7. Also, we create a database user and grant permission too.

For example,

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';

8. Again, we find mail files. Normally, it will show as follows

home/user/mail/yourdomainname.com/mailaccountname/

7. We create an email account in the new server and copy the content from the old email folder to the new one.

8. finally, we check the ownership and permissions and if it set wrongly, we’ll correct it.

 

Restoring of single cPanel Account to another cPanel server.

When the source and destination servers both have cPanel, restore of Cpanel backup becomes pretty simple.

Basically, our Migration Engineers use this method to restore the Individual cPanel Account to another server.

1. initially, we log-in to the server that you want to migrate as a root user.

2. To generate a backup we use the following command.

/scripts/pkgacct username

After running the command, a backup will create in the directory where you are. Here, we generate backup in the home directory.

3. Then we transfer the backup to another server with SCP command.

scp /home/cpmove-user.tar.gz root@x.x.x.x:/home

4. After that, we restore the cPanel account backups. So, we enter the following command.

/scripts/restorepkg username

This command will restore all settings, files, and databases from the old cPanel server to the new cPanel server.

 

How we fixed the common errors

From our experience in managing servers, we’ve seen customers facing problems when migrating accounts from cPanel server to another server.

Now, it’s the time to take a closer look at what causes the migration error.

 

1. Duplicate user

Recently, one of our customers reported a backup restoring problem. When he tried to restore the backup from cPanel, he was getting an error as follows.

Cannot restore. That user already exists on this system

So, our Migration Engineers used the following command to find the user in the server.

find / -name "username"

The output indicated presence of the user on the server and looked as below.

/var/spool/cron/username
/var/cagefs/16/username
/home/virtfs/jeyaprak/var/spool/cron/username
/home/virtfs/jeyaprak/var/cagefs/16/username
/etc/proftpd/username

Therefore, we deleted the entries manually from the command line. That fixed the problem and restore worked successfully.

Sometimes, the user name can be found in /etc/passwd and /etc/group files too. In such cases, we open the files /etc/passwd and /etc/group, then remove the entries related to the user.

 

2. Permission and ownership

Occasionally, after moving the old server to the new server, clients get website errors because of insufficient user permissions and ownership.

Since most migration happen with root user, the files will be still in the ownership of root user. This create problems with the website, emails, etc.

Here, we correct the ownership and permissions of migrated site files. We set the ownership of the website files and folders to site user. The default file permission should be 644 and the directory should be 755.

 

[Having trouble while migrating cPanel to another server? We’ll copy your files without any data loss.] 

 

Conclusion

In short, restore of cPanel backup via command line requires knowledge in migration techniques. Today, we saw how our Migration Engineers restore cPanel backup and fix related errors.

Leave a Comment

Your email address will not be published. Required fields are marked *

Social Share

Facebook
Twitter
LinkedIn
Telegram

Cheapest Web Hosting

Fasters Web Hosting Promo
Scroll to Top

Launch your Website at RS599

Create a professional website yourself with our domain hosting combo. Get Extra benefits at this Year end Sale with 10% OFF and Enjoy Amazing Deels on Shared Hosting!

Starting at Only RS599/Year

Year End Sale

Hours
Minutes
Seconds

Use Code STARTBIZ at Checkout.

Create an earning opportunity with A Web Hosting Business

Become reseller and start reselling domains, web hosting, ssl certificates and More.

45% OFF

Starting at RS399/Month

Hours
Minutes
Seconds

Use coupon: at the checkout.