Warning : This is not to be done by the unexperienced admins .
Sometimes when the server get hacked or boot from a bad kernel you need to have the datacenter mount your old drive, and install a new one with a fresh installation. This topic will guide you how to restore a complete server to a new one form the old drive which is mounted as secondary drive to the server.
I. Mount the backup Drive
First check to see if there are any drives mounted.
If it is not mounted, please mount manually the old drive to any location, say /mnt/old
For that please do the following:
fdisk -l
check for additional drives, in this tutorial we will use /dev/hdc3.
mount /dev/hdb3 /mnt/old
now that the drive is mounted you can browse files like:
ls /mnt/old/home
II. Rsync the files
Do these commands one by one,
rsync -vrplogDtH /mnt/old/usr/local/apache/conf /usr/local/apache
rsync -vrplogDtH /mnt/old/var/named /var
rsync -vrplogDtH /mnt/old/home/* /home
rsync -vrplogDtH /mnt/old/usr/local/cpanel /usr/local
rsync -vrplogDtH /mnt/old/var/lib/mysql /var/lib
rsync -vrplogDtH /mnt/old/var/cpanel /var
rsync -vrplogDtH /mnt/old/usr/share/ssl /usr/share
rsync -vrplogDtH /mnt/old/var/ssl /var
rsync -vrplogDtH /mnt/old/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
rsync -vrplogDtH /mnt/old/var/log/bandwidth /var/log
rsync -vrplogDtH /mnt/old/usr/local/frontpage /usr/local
rsync -vrplogDtH /mnt/old/var/spool/cron /var/spool
Next Step – Get some important files from etc:
cd /mnt/old/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 /etc
Now would be a good time to change your password for root:
passwd
III. Updating software and restarting services
/scripts/upcp
/scripts/updatenow
/scripts/sysup
/scripts/fixeverything
/scripts/exim4
/scripts/easyapache
/scripts/securetmp
This is needed to update cpanel information. Please note, sshd might fail and not start after running fixeverything. You have to login to whm, and go to the rpm installer and “FORCE” install opensshd-server, opensshd, opensshd-client and then restart sshd from whm.
IV. Restarting services
/scripts/restartsrv httpd
/scripts/restartsrv cpanel
/scripts/restartsrv mysql
/scripts/restartsrv named
/scripts/restartsrv exim
Thats all. This will work 100% in redhat and fedora OS. It will work fine on FreeBSD except slight changes in 2 lines:
rsync -vrplogDtH /mnt/old/var/lib/mysql /var/lib
should be:
rsync -vrplogDtH /mnt/old/var/db/mysql /var/db
and also after running “cd /mnt/old/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 /etc
should be:
rsync -vrplogDtH secondarymx domainalias valiases vfilters exim* cpupdate.conf quota.conf master.passwd* *rndc* ips* ipaddrpool* ssl /etc
Other than that rest will work fine and should restore all accounts and settings.
Leave A Comment
You must be logged in to post a comment.