1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Migrate to cPanel' started by devbau.com, Apr 18, 2011.

  1. devbau.com

    devbau.com New Member

    Joined:
    Sep 8, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    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
     
    #1 devbau.com, Apr 18, 2011
    Last edited: Apr 18, 2011
  2. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    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 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:

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

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

    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.
     
  3. devbau.com

    devbau.com New Member

    Joined:
    Sep 8, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
    #3 devbau.com, Apr 18, 2011
    Last edited: Apr 18, 2011
  4. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    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.
     

Share This Page