Monday, January 12, 2009

Migrating cPanel reseller accounts with root WHM access

We have a few clients that were WHM resellers and upgraded to VPS with root cPanel, however there is no main easy way to migrate WHM reseller account to a root account under WHM, that’s where we started playing around and making our own script. You need root access to the source and final server to do this, this looks like the fastest way to do this at the moment.

First of all, we need to get all the accounts and create a backup of their accounts, this is done using a couple of bash lines and parsing the file /etc/trueuserowners. That file contains every account on the server and the accounts that own it. This following will go over that file, take out the resellers accounts and back them up one by one. The best way to make sure no mistake happens is to ensure that /home or /home2 or any other /home directories because the /scripts/pkgacct creates them there. We also use cpuwatch not to create excessive load on the server when creating the backup. It will stop the process once load averages go higher than 10.

for i in `cat /etc/trueuserowners | grep resellerusername | awk -F ‘:’ ‘{ print $1; }’`;
do /usr/local/cpane/bin/cpuwatch 10 /scripts/pkgacct $i;
done;

Usually this takes a while so this is what you can do if it’s halfway done to save time

/usr/bin/rsync --delete -avvxHt --progress -e ssh /home/cpmove-* 1.2.3.4:~

This will start moving the files from the old server to the new one, we use rsync so that we can just run it again after the full backup is done so we don’t have to restart the whole process again. Once it’s done and all data has been moved, another loop, I did this one quickly however I think it could be cleaner, if someone has a better way to do with (regexp?), please let me know.

for i in `ls | grep cpmove- | awk -F '.' '{ print $1 }' | awk -F '-' '{ print $2 }'`;
do /scripts/restorepkg $i;
done;

After finishing that, you should be all done!

2 comments:

Anonymous said...

Thanks a lot for sharing these useful guidelines here,Website Hosting

Unknown said...

Great post, I appreciate you and I would like to read your next post. Thanks for sharing this useful information.
Master Reseller