Featured Posts

Tips to Reduce Your Customer Support Costs When hosting websites, whether as a mainstream hosting provider, a hobby, or to supplement another service, it's your job to make sure your customers have access to technical support in case they need...

Read more

Roundcube: MySQL or SQLite? cPanel 11.25 introduces a new feature: The ability to have RoundCube use SQLite instead of MySQL. After benchmarking resource usage and performance, I've come to the conclusion that SQLite is definitely...

Read more

Simple Bash Script to Fix Account Permissions This is a simple bash script I wrote to fix the permissions and ownership of files within a cpanel account. To use, simply copy the script your server, chmod 755, and pass the usernames as arguments: ./fixperms...

Read more

Re-Installing Auxiliary cPanel Software Cpanel has a lot of supporting software that you may be using on your server. In case something goes amiss, here is a list of scripts that reinstall cpanel-provided software on your system. For most all...

Read more

10 Free Monitoring Solutions to Consider Server and network monitoring can be crucial to a host's success. I mean, how embarrassing is it when your customers are aware of downtime before you are? You don't have to pay big bucks or spend loads...

Read more

The cPanel Admin Rss

Manually Rearranging Accounts

Posted by Vanessa | Tagged under , | 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/*/passwd

done

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.

Liking this article? Share it and spread the word!
  • Print
  • PDF
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Related posts:

Write a comment