Tag Archives: migrate accounts from cpanel using a script

Migrate all accounts from a cPanel server to another one !

Yes, you have got the WHM option of migrating the accounts. However, most chances are for it to fail.

Also, you cannot keep your eyes on the screen and watch the progress. What if your local internet connection breaks in between this ? It ends up in a mess and more work for the Administrator.

So, its preferred to migrate your accounts from the back-end. Following set of commands and a small script will help you.

#  screen -S acttransfer ( Running the commands in a screen is always the safest option )
# ls /var/cpanel/users > fulllist.txt

# vi backupscript.sh


#! /bin/bash
for i in `cat fulllist.txt`; do /scripts/pkgacct $i; done
scp -r /home/cpmove* root@server:/home

# chmod +x backupscript.sh

# ./backupscript.sh

You will have to manually type in the root password of the other server when scp prompts. More easy is to set up a key-based authentication so that you wont have to glance even.  Check here on setting up key-based authentication for your server.

On the destination server, you can use this one-liner to restore all the accounts ( Make sure you transfer/copy the file  ‘fulllist.txt ‘ to the destination server  )

# for i in `cat fulllist.txt`; do /scripts/restorepkg $i; done