Recover cPanel from crashed OS/hard disk


Sometimes operating system or hard drive crashes and makes your system un-bootable. Don’t panic. There are still chance that you recover all or most of your data. Call you data center and ask them to install OS on a new hard disk and mount your crashed disk as secondary drive. Once your server is up and running on the new operating system. Install cPanel on it and mount the old hard disk.

mkdir /mnt/OldDisk
mount /dev/sdb1 /mnt/OldDisk
mount /dev/sdb2 /mnt/OldDisk/home
mount /dev/sdb3 /mnt/OldDisk/var

Now rsync all the data from crashed disk to new disk.

rsync -vrplogDtH /mnt/OldDisk/usr/local/apache/conf /usr/local/apache
rsync -vrplogDtH /mnt/OldDisk/var/named /var
rsync -vrplogDtH /mnt/OldDisk/home/* /home
rsync -vrplogDtH /mnt/OldDisk/usr/local/cpanel /usr/local
rsync -vrplogDtH /mnt/OldDisk/var/lib/mysql /var/lib
rsync -vrplogDtH /mnt/OldDisk/var/cpanel /var
rsync -vrplogDtH /mnt/OldDisk/usr/share/ssl /usr/share
rsync -vrplogDtH /mnt/OldDisk/var/ssl /var
rsync -vrplogDtH /mnt/OldDisk/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
rsync -vrplogDtH /mnt/OldDisk/var/log/bandwidth /var/log
rsync -vrplogDtH /mnt/OldDisk/usr/local/frontpage /usr/local
rsync -vrplogDtH /mnt/OldDisk/var/spool/cron /var/spool
rsync -vrplogDtH /mnt/OldDisk/root/.my.cnf /root
rsync -vrplogDtH /mnt/OldDisk/etc/httpd/conf/httpd.conf /etc/httpd/conf

Now rsync the configuration files.

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

Now change the root password again as you have now replaced the passwd file

Changing password for user root.
New password:

Force update the cpanel and run easyapache

/scripts/upcp --force
/scrtips/easyapache --force

Restart all the services

#/scripts/restartsrv httpd
#/scripts/restartsrv cpanel
#/scripts/restartsrv mysql
#/scripts/restartsrv named
#/scripts/restartsrv exim


Sreejit is the founder of Server Management Plus. He has created a lots of automation scripts for the company using which we are able to resolve issue at an extremely fast rate and save lots of time. He has a very keen interest in new technologies and spend most of his free time online researching about it apart from listening music and watching movies.

1 thought on “Recover cPanel from crashed OS/hard disk”

  1. Here the recovery of the cPanel is very informative. In the server cPanel is a very important tool web site. Here command is very precise and informative. Very knowledgeable.

Comments are closed.