This article teaches HOW-TO restore accounts from a crashed or failed HDD to a new one without moving and restore backups and losing a lot of time.
First of all plug the crashed HDD to USB and install a new system on the new HDD.
After installing the system and cpanel login as root to SSH and write these commands one after one:
rsync -vrplogDtH /oldHD/usr/local/apache/conf /usr/local/apache
rsync -vrplogDtH /oldHD/var/named /var
rsync -vrplogDtH /oldHD/home/* /home
rsync -vrplogDtH /oldHD/usr/local/cpanel /usr/local
rsync -vrplogDtH /oldHD/var/lib/mysql /var/lib
rsync -vrplogDtH /oldHD/var/cpanel /var
rsync -vrplogDtH /oldHD/usr/share/ssl /usr/share
rsync -vrplogDtH /oldHD/var/ssl /var
rsync -vrplogDtH /oldHD/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
rsync -vrplogDtH /oldHD/var/log/bandwidth /var/log
rsync -vrplogDtH /oldHD/usr/local/frontpage /usr/local
rsync -vrplogDtH /oldHD/var/spool/cron /var/spool
rsync -vrplogDtH /oldHD/root/.my.cnf /root
rsync -vrplogDtH /oldHD/etc/httpd/conf/httpd.conf /etc/httpd/conf
After finishing this:
rsync -vrplogDtH secondarymx domainalias valiases vfilters exim* proftpd* pure-ftpd* passwd* group* *domain* *named* wwwacct.conf cpupdate.conf quota.conf shadow* *rndc* ips* ipaddrpool* ssl hosts /etc
If you don't have RSYNC then you should install it from:
Or you could use "mv" instead of "rsync -vrplogDtH" but I recommend using RSYNC because I used it before on my server and it doesn't make any errors or problems now or in the future.
All the files have been copied you shall now make the cpanel recognize again the old users, Run these scripts:
The last one may take a long time depending on your CPU and RAM speed.
After doing all of that if SSHD fails, then you have to login to WHM then go to Install a RPM and install opensshd-server, opensshd, opensshd-client then restart SSHD from WHM.
Then restart all the services:
After those steps you will face a small problem. Login to WHM then go to Reseller Cener, You will see that all the accounts under the root tab only and there is no other reseller or other plan !!!
Don't get worry, It just needs to do something like refreshed, If you suspend an account it will be sorted under it's reseller but you won't suspend and unsuspend all the accounts, I found a simple way for doing that.
Login to WHM then click on Modify/Upgrade Multiple Accounts and mark all the accounts then just change the Language to be English or something else. Click on Reseller Center again. Waaw the account has been sorted under its resellers and all things are working properly right now ;)
Copied from http://blog.eukhost.com/webhosting/restoring-cpanel-server-from-crashed-harddisk-or-migrating-cpanel-servers/
but added some notes, modifications and FAQ.
How to know that you're facing this problem and this article will help you ?
1. If you when on SSH a message appears contains
Message from syslogd@ at XXX XXX XX XX:XX:XX XXXX ...
XXXXX kernel: journal commit I/O error
The first line XXX means date and the second line XXXXX means your server's hostname.
and also when you try to write to file you can't as the system puts the HDD on the read-only mode. You can solve this by rebooting the server also make FSCK to check the HDD. When you reboot and this problem still presist and happens again and again then your HDD can't stand the errors happen on it. Then its time to swap it and follow this article steps.
2. When all of your websites have a 500 Internal Server Error.
Keep in mind that it can be your suphp_log file is 2GB and can't write any data then you have to rotate it.
3. When you logged to SSH and it appears that is 0 Users are in. (May not happen)
4. If you have cPanel.
Will that article help me completely solve this issue ?
Yes, It will completely help you solving this issue.
Is that article is tested ?
Yes, It's tested on CentOS5 32-bit with cPanel/WHM.
What is the specifications of the machine that this article tested on ?
Dual Processor Quad Core Xeon 5430 - 2.66GHz (Harpertown) - 2 x 12MB cache
12GB of Ram
2 x 250GB HDD
What was the Apache, PHP and MySQL version when this problem presist ?
Do Apache, PHP and MySQL have a hand in this problem ?
A little bit as the best tuning of Apache and MySQL would help this problem to not happen.
Do I have to be professional to do these steps ?
Not at all, These steps are so easy to follow and don't need an expertised person.
How can I prevent this problem from happening again ?
Maybe you need more processor, more ram, tuning of Apache and MySQL and definitely a RAID cable to lower the number of errors on one HDD.
Will I face some problems when I follow these steps ?
Maybe you will face "File not found" problem but ignore it as it doesn't matter.
The data has been moved from the old HDD to the new one fastly and easily without losing time or data. Also there won't be errors after doing these step as I explained. These steps has been tested before in my server when my HDD crashed. If you want this problem to end completely then you have to put 2HDDs at RAID to make them like mirrors to each other.