<

Restore a cPanel server from Crashed HDD to a new one without using backups

Published on
10,856 Points
4,856 Views
Last Modified:
Approved
Introduction:

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.

Explanation:

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

Open in new window


After finishing this:
cd /oldHD/etc
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

Open in new window



Note: If you don't have RSYNC then you should install it from:
http://www.samba.org/rsync/download.html
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:
/scripts/upcp
/scripts/updatenow
/scripts/sysup
/scripts/exim4
/scripts/securetmp
/scripts/fixeverything
/scripts/easyapache

Open in new window

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:
/scripts/restartsrv httpd
/scripts/restartsrv cpanel
/scripts/restartsrv mysql
/scripts/restartsrv named
/scripts/restartsrv exim

Open in new window


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 ;)

Note: Copied from http://blog.eukhost.com/webhosting/restoring-cpanel-server-from-crashed-harddisk-or-migrating-cpanel-servers/ but added some notes, modifications and FAQ.

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.
Note: 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 ?
Apache 2.2.11
PHP 5.2.9
MySQL 5.0.81

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.

Conclusion:

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.
0
Comment
0 Comments

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Join & Write a Comment

Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month