How to manually (terminal, command line) backup, migrate, restore single user account

devbau.com

Registered
Sep 8, 2009
4
0
51
How to manually (terminal, command line) backup, migrate, restore single user account?

Approach below, helps to manage tasks over terminal, which is a much faster way to handle the task.

Run on source server:

Code:
/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:
Code:
cd /home
wget http://$userdomain/cpmove-$user.tar.gz
/scripts/restorepkg $user
After successfull migration run on source server

Code:
/scripts/killacct $user
Replace $user with your user account name and $userdomain with user domain name
 
Last edited:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: How to manually (terminal, command line) backup, migrate, restore single user acc

I would not suggest placing your backup into public_html where the entire world could then retrieve it even if for a short time period. It is faster and easier to simply scp the backup to the new machine:

Code:
/scripts/pkgacct $user
scp /home/cpmove-$user.tar.gz [email protected]:/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:

Code:
/scripts/pkgacct $user
scp -P port# /home/cpmove-$user.tar.gz [email protected]:/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:

Code:
/scripts/pkgacct $user
scp -P port# /home/cpmove-$user.tar.gz [email protected]:./
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:

Code:
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.
 

devbau.com

Registered
Sep 8, 2009
4
0
51
Re: How to manually (terminal, command line) backup, migrate, restore single user acc

Thank you for great suggestions. Your case is working when ssh with passwords is available. If certs are required, then it's easier to do as i suggested. Og course there is an option to temporarily to make available access without cetts too and to use your suggested method, or share certs.

When security is a bit mote important, your case is better solution. If even moro higher security is required, then of course shall be considered better methods for file transfers.

But for avoiding bad habits, its always better to use most secure ways.
 
Last edited:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,606
33
238
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: How to manually (terminal, command line) backup, migrate, restore single user acc

The commands you provided are SSH commands on both machines, so it would seem both machines have SSH access to get onto them.