How to restore cpanel backup with new username

Everybody knows, how to restore the cpanel backup using scripts command but most of us doesn’t know how to restore the cpanel backup with new username. In older version its not possible but In new version (WHM 11.44.1 (build 11)) its possible. Follow the below steps to do it.




For testing purpose, i’m playing this testing with cloudana account.

  • Take backup of corresponding account
  • Terminate the account
  • Restore the account with new username

Syntax :

Use the below syntax to restore the cpanel backup with new username. Instead of newusername you need to give your newusername whatever you want.

# /scripts/restorepkg --newuser newusername /path/to/backup/file

1) See blow list of hosted account in our server and I planning to test cloudana account.

[email protected] [/home]# ls -lh
total 40.0K
drwx--x--x   8 root             root             4.0K Jun 13 13:09 backup/
drwx--x--x  14 cloudana         cloudana         4.0K Aug  5 10:02 cloudana/
drwxr-xr-x   5 root             root             4.0K Oct 20  2012 .cpan/
drwxr-xr-x   3 root             root             4.0K Aug  6 01:20 .cpanm/
drwx------   4 root             root             4.0K Aug  6 01:20 .cpcpan/
drwx------   3 root             root             4.0K Oct 20  2012 cpeasyapache/
drwx------   2 root             root             4.0K Jan 30  2014 cprestore/
drwx--x--x  12 dev2daygeek      dev2daygeek      4.0K Aug  2 01:03 dev2daygeek/
drwx--x--x  17 email3se         email3se         4.0K Aug  2 01:03 email3se/
drwx------   2 nagios           nagios           4.0K Jan  4  2013 nagios/
drwx--x--x  11 openmeeting2dayg openmeeting2dayg 4.0K Aug  2 01:32 openmeeting2dayg/
drwx--x--x  11 support2daygeek  support2daygeek  4.0K Aug  2 01:32 support2daygeek/
drwx--x--x   3 root             root             4.0K Nov  5  2013 virtfs/

2) Taking backup of cloudana account using scripts command.

[email protected] [/home]# /scripts/pkgacct cloudana
pkgacct started.
pkgacct using '/usr/bin/gzip -6' to compress archives
pkgacct working dir : /home/cpmove-cloudana
.
.
Done
pkgacctfile is: /home/cpmove-cloudana.tar.gz
md5sum is: dad9f6b9848c85cc64f8f4b28a210850

size is: 1049699438

homesize is: 1509277696

3) Verifying the backup file. Yes, its there.

[email protected] [/home]# ls -lh
total 926M
drwx--x--x   8 root             root             4.0K Jun 13 13:09 backup/
-rw-------   1 root             root             926M Jul  4 13:45 backup-7.4.2014_13-44-24_cloudana.tar.gz
drwx--x--x  14 cloudana         cloudana         4.0K Aug  5 10:02 cloudana/
drwxr-xr-x   5 root             root             4.0K Oct 20  2012 .cpan/
drwxr-xr-x   3 root             root             4.0K Aug  6 01:20 .cpanm/
drwx------   4 root             root             4.0K Aug  6 01:20 .cpcpan/
drwx------   3 root             root             4.0K Oct 20  2012 cpeasyapache/
drwx------   2 root             root             4.0K Jan 30  2014 cprestore/
drwx--x--x  12 dev2daygeek      dev2daygeek      4.0K Aug  2 01:03 dev2daygeek/
drwx--x--x  17 email3se         email3se         4.0K Aug  2 01:03 email3se/
drwx------   2 nagios           nagios           4.0K Jan  4  2013 nagios/
drwx--x--x  11 openmeeting2dayg openmeeting2dayg 4.0K Aug  2 01:32 openmeeting2dayg/
drwx--x--x  11 support2daygeek  support2daygeek  4.0K Aug  2 01:32 support2daygeek/
drwx--x--x   3 root             root             4.0K Nov  5  2013 virtfs/

4) Terminating cloudana account from cpanel

[email protected] [/home]# /scripts/killacct cloudana
Are you sure you want to remove the account "cloudana" [y/N]? y
Running pre removal script (/usr/local/cpanel/scripts/prekillacct)......Done
.
.
Updating internal databases......Done
Running post removal scripts (/usr/local/cpanel/scripts/legacypostkillacct, /usr/local/cpanel/scripts/postkillacct)......Done
Account Removal Complete!!!......Done
info [killacct] User cloudana removed
User: cloudana
Domain: cloud.2daygeek.com
Locking password for user cloudana.
passwd: Success
Removed the following non-SSL virtual hosts: cloud.2daygeek.com
Removed the following SSL virtual hosts:
Removed DB cloudana_cloud
Database "cloudana_cloud" dropped
SuccessRemoving /etc/valiases/cloud.2daygeek.com
System has 2 free ips.

Id: TQ:TaskQueue:774
Updating FTP passwords for cloudana
Purging ftp user cloudana
FTP password files updated.
FTP vhost passwords synced
cloudana account removed

5) Restoring the same domain with different/new username.

[email protected] [/home]# /scripts/restorepkg --newuser cloud2g /home/backup-7.4.2014_13-44-24_cloudana.tar.gz
Attempting restoration of the account backup “/home/backup-7.4.2014_13-44-24_cloudana.tar.gz” (type: backup) …
The account backup to restore is a file: /home/backup-7.4.2014_13-44-24_cloudana.tar.gz
cPanel restorepkg
Archive user: “cloudana”
New user: “cloud2g”
Restricted: “no”
Allow Reseller Privileges: “no”
The system will attempt to restore the archive file “/home/backup-7.4.2014_13-44-24_cloudana.tar.gz”.
ArchiveManager
                Preparing archive for restoration …
.
.
.
Quota
                Restoring quota
                Using Universal Quota Support (quota=0)
        Quota
Account Restored

6) Verifying the restored account username details in home directory. Yes, its restored with new username and also created soft link

[email protected] [/home]# ls -lh
total 926M
drwx--x--x   8 root             root             4.0K Jun 13 13:09 backup/
-rw-------   1 root             root             926M Jul  4 13:45 backup-7.4.2014_13-44-24_cloudana.tar.gz
drwx--x--x  14 cloud2g          cloud2g          4.0K Aug  8 10:34 cloud2g/
lrwxrwxrwx   1 root             root               13 Aug  8 10:31 cloudana -> /home/cloud2g/
drwxr-xr-x   5 root             root             4.0K Oct 20  2012 .cpan/
drwxr-xr-x   3 root             root             4.0K Aug  6 01:20 .cpanm/
drwx------   4 root             root             4.0K Aug  6 01:20 .cpcpan/
drwx------   3 root             root             4.0K Oct 20  2012 cpeasyapache/
drwx------   2 root             root             4.0K Jan 30  2014 cprestore/
drwx--x--x  12 dev2daygeek      dev2daygeek      4.0K Aug  2 01:03 dev2daygeek/
drwx--x--x  17 email3se         email3se         4.0K Aug  2 01:03 email3se/
drwx------   2 nagios           nagios           4.0K Jan  4  2013 nagios/
drwx--x--x  11 openmeeting2dayg openmeeting2dayg 4.0K Aug  2 01:32 openmeeting2dayg/
drwx--x--x  11 support2daygeek  support2daygeek  4.0K Aug  2 01:32 support2daygeek/
drwx--x--x   3 root             root             4.0K Nov  5  2013 virtfs/

We are preparing all articles in-depth to understand by all level/stage Linux administrators. If the article is useful for you, then please spend less than a minute to share your valuable comments in our commenting section.

Please stay tune with us…Good Luck.

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...