Is it possible to Migrate cPanel accounts without its home directory? Yes! It is possible to migrate cPanel accounts without home directory information. The idea is to generate a cPanel full backup, but excluding the home directory contents. This is specially useful when the home directory is really big and you plan to migrate it separately.
Let’s say you have a 100GB backup to generate, and 90GB are from the home directory, this will take hours. Instead of this you can generate a cpanel backup excluding the home directory to save time.
How can I Migrate cPanel accounts without its home directory?
For this we will use an internal cPanel script called /scripts/pkgacct
/scripts/pkgacct --skiphomedir nixcp
This will generate a cPanel full backup without home directory content, this will include:
- Email files & Mail Lists
- cPanel configurations
- SSL Certificates
- DNS Zones
- WWW Logs
- Quote and Bandwidth Statistics
- PGSQL and MySQL Databases with users and privileges.
This is the expected output:
[email protected] [/home]# /scripts/pkgacct --skiphomedir nixcp [2017-01-16 05:04:49 -0600] pkgacct started. [2017-01-16 05:04:49 -0600] pkgacct version 10 - user : nixcp - tarball: 1 - target mysql : default - split: 0 - incremental: 0 - homedir: 0 - mailman: 1 - backup: 0 - archive version: 3 - running with uid 0 [2017-01-16 05:04:49 -0600] pkgacct using '/usr/local/cpanel/3rdparty/bin/pigz -6 --processes 1 --blocksize 4096 --rsyncable' to compress archives [2017-01-16 05:04:50 -0600] pkgacct working dir : /home/cpmove-nixcp [2017-01-16 05:04:50 -0600] Copying Reseller Config...[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying Suspension Info (if needed)...[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying SSL certificates, CSRs, and keys...[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Storing SSL domain......[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying Domain Keys....[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying Counter Data....[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying Bandwidth Data....Summary databases … done! [2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying Dns Zones.......nixcp.com...[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying Mail files....[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying proftpd file....[2017-01-16 05:04:50 -0600] Done [2017-01-16 05:04:50 -0600] Copying www logs.......log file sizes [1100833352 byte(s)]............ ...nixcp.com......ftp.nixcp.com-ftp_log......ftp.nixcp.com-ftp_log.offset......nixcp.com-bytes_log......ftp.nixcp.com-ftp_log.offsetftpbytes...[2017-01-16 05:04:51 -0600] Done [2017-01-16 05:04:51 -0600] Copy userdata...[2017-01-16 05:04:51 -0600] Done [2017-01-16 05:04:51 -0600] Copy custom virtualhost templates...[2017-01-16 05:04:51 -0600] Done [2017-01-16 05:04:51 -0600] Copying mailman lists and archives....[2017-01-16 05:04:51 -0600] Done copying mailman lists and archives. [2017-01-16 05:04:51 -0600] Performing “Postgresql” component.... [2017-01-16 05:04:51 -0600] Completed “Postgresql” component. [2017-01-16 05:04:51 -0600] Performing “Mysql” component.... [2017-01-16 05:04:51 -0600] Determining mysql dbs...[2017-01-16 05:04:51 -0600] ...mysqldump version: 5.5.52...[2017-01-16 05:04:51 -0600] ...mysql version: 5.5...[2017-01-16 05:04:51 -0600] Saving mysql privs...[2017-01-16 05:04:51 -0600] Done [2017-01-16 05:04:51 -0600] ...Done [2017-01-16 05:04:51 -0600] Storing mysql dbs............ nixcp[2017-01-16 05:04:53 -0600] (111411042 bytes) [2017-01-16 05:04:53 -0600] ...Done [2017-01-16 05:04:53 -0600] Completed “Mysql” component. [2017-01-16 05:04:53 -0600] Copying cpuser file.......[2017-01-16 05:04:53 -0600] Done [2017-01-16 05:04:53 -0600] Copying crontab file.......[2017-01-16 05:04:53 -0600] Done [2017-01-16 05:04:53 -0600] Performing “Quota” component.... [2017-01-16 05:04:53 -0600] Completed “Quota” component. [2017-01-16 05:04:53 -0600] Performing “Integration” component.... [2017-01-16 05:04:53 -0600] Completed “Integration” component. [2017-01-16 05:04:53 -0600] Performing “AuthnLinks” component.... [2017-01-16 05:04:53 -0600] Completed “AuthnLinks” component. [2017-01-16 05:04:53 -0600] Storing Subdomains.... [2017-01-16 05:04:53 -0600] Done [2017-01-16 05:04:53 -0600] Storing Parked Domains.... [2017-01-16 05:04:53 -0600] Done [2017-01-16 05:04:53 -0600] Storing Addon Domains.... [2017-01-16 05:04:53 -0600] Copying password.......[2017-01-16 05:04:53 -0600] Done [2017-01-16 05:04:53 -0600] Copying shell.......[2017-01-16 05:04:53 -0600] Done [2017-01-16 05:04:53 -0600] Creating Archive .................................................................................... ................................................................................ ................................................................................ ...................................................................... [2017-01-16 05:05:24 -0600] Done [2017-01-16 05:05:24 -0600] pkgacctfile is: /home/cpmove-nixcp.tar.gz [2017-01-16 05:05:25 -0600] md5sum is: 9561495a4f7ac64a24a30db0f0308959 [2017-01-16 05:05:25 -0600] [2017-01-16 05:05:25 -0600] size is: 160061269 [2017-01-16 05:05:25 -0600] pkgacct completed [email protected] [/home]#
How can I transfer my cpanel backup to my new server?
You can use rsync to transfer your backup to the new box.
Run this command on your destination box:
rsync -avpr -e 'ssh -p 22' [email protected]:/home/cpmove*.tar.gz /home
In this example you must replace this items to match your origin (old) server:
22 with your real SSH port.
111.111.111.111 with your real Server IP address.
How can I restore the cPanel backup on my new server?
You can do it by running this command:
cd /home /scripts/restorepkg cpmove-user.tar.gz
Make sure you replace “cpmove-user.tar.gz” with your real backup file name.
The output should look something like this:
[[email protected]:~]/scripts/restorepkg cpmove-nixcp.tar.gz Attempting restoration of the account backup “cpmove-nixcp.tar.gz” (user: nixcp) … cPanel restorepkg version: 2.3 Archive user: nixcp Restricted: no Allow Reseller Privileges: no The system will attempt to restore the archive file “/home/cpmove-nixcp.tar.gz”. ... ... ...
Generate and restore mass cPanel backup without home directory content
Use this for loop to generate mass cpanel backups without homedir:
cd /var/cpanel/users for i in *; do /scripts/pkgacct --skiphomedir $i; done
Execute the following command to restore all the backups on the destination server:
cd /home for i in `ls -alh cpmove*.tar.gz`; do /scripts/restorepkg $i; done
All done, now you know how to migrate cPanel accounts without its home directory to avoid generating huge .tar.gz files and improve migration times.
Further reading: