Manually Rearranging Accounts
Posted by Vanessa | Tagged under howto,tips | Posted on July 14, 2010
0
There was a situation today where I had to mass-move a bunch of accounts from one partition to another. WHM’s Rearrange an Account function does this one account at a time, but to move over 50 of them, a more scripted solution was necessary. Here’s how I did it on a live server without causing any downtime:
Scenario: Moving over 50 cPanel accounts from /home4 to /home3 on a live dedicated server
Step 1: Grab the list of users
Done with a simple one-liner:
for user in `cat /etc/passwd | grep /home/ | cut -d: -f1` ; do echo $user >> /root/users ; done
Step 1: Rsync all the data over
This part can be fairly CPU-intensive, so you may want to bandwidth-limit or renice the rsync which will slow the transfer, even if done locally. You need to copy the data on one disk to the other:
for user in `cat users` ; do rsync -av --bwlimit=8000 --delete /home4/$i /home3 ; done
You may want to run this command a few times depending on how much data is being moved over.
Step 3: Update configuration
Paste the following commands into a file (replacing the partition names with the ones pertaining to your server), chmod 755, and run:
for user in `cat user` ; do
replace /home4/ /home3/ — /var/cpanel/userdata/$user/*
replace /home4/ /home3/ — /etc/proftpd/$user
replace /home4/$user /home3/$user — /etc/passwd
ln -s /home4/$user /home3/$user
replace /home4/$user /home3/$user — /home3/$user/etc/*/passwddone
Now, run:
/scripts/rebuildhttpconf && service httpd restart
service pure-ftpd restart (or proftp)
When you’re sure that everything is moved over, you can remove all the user data from the old partition.
Related posts:






sending...