June 23, 2015

How to Backup and Restore cPanel Accounts via SSH

Log-in to the SSH as Root user.
Run on source server:

Method 1:

/scripts/pkgacct $user
mv cpmove-$user.tar.gz /home/$user/public_html
chmod 644 /home/$user/public_html/cpmove-$user.tar.gz

Run on destination server:

cd /home
wget http://$userdomain/cpmove-$user.tar.gz
/scripts/restorepkg $user

After successfull migration run on source server

/scripts/killacct $user

Replace $user with your user account name and $userdomain with user domain name

Method 2 (Recommend): It is faster and easier to simply scp the backup to the new machine.

/scripts/pkgacct $user
scp /home/cpmove-$user.tar.gz root@destinationIP:/home/

You'd replace $user with the cPanel username, destinationIP with the IP number for the new machine. After running the second command, you would be prompted for the password for the destination server.

Now, if you end up having SSH running on an alternate port on the destination machine rather than port 22, you'd simply add this section:

/scripts/pkgacct $user
scp -P port# /home/cpmove-$user.tar.gz root@destinationIP:/home/

Replace port# with the alternate port on the destination machine.

If you have root user locked down where you cannot SSh as that user, simply scp to a sudo user's home that has shell access:

/scripts/pkgacct $user
scp -P port# /home/cpmove-$user.tar.gz sudousername@destinationIP:./

At that point, you'd replace sudousername with the sudo user that has shell access. This would save a copy of the cpmove-$user.tar.gz file to /home/subousername location. You'd then log into the destination machine, sudo su - to root and move the file from /home/sudousername to /home instead:

mv /home/sudousername/cpmove-$user.tar.gz /home

After you have the account on the destination machine, then you can run "/scripts/restorepkg $user" at that point.

https://forums.cpanel.net/threads/how-to-manually-terminal-command-line-backup-migrate-restore-single-user-account.204311/

0 comments:

Post a Comment