restore cpanel server after harddisk fail
Today Primary hard disk of a server failed.
Data center reloaded OS in a new Hard Disk and mounted old Hard Disk as secondary for copying data back to new hard disk.
MOUNT OLD HARD DISK
Many data center will connect second hard disk to your server, but won't mount the HDD on the server.
To find and mound secondary hard disk, following commands will help.
Get List of Hard Disk and Partitions
Will list available Hard disks and partitions available on each of these hard disks.
Find Which Partition is OLD HDD
To get list of parsons used.
With this, you will get an idea of which Hard disk is primary and which secondary (old HDD).
The device that mounted partitions like /, /home, /usr, /var, /tmp will be the new HDD.
Also df -h will show if the secondary hard disk is mounted or not.
In Linux, first HDD is
/dev/hda or /dev/sda (for sata)
Second Hard disk
/dev/hdb or /dev/sdb (for sata)
List all the partitions that are mounted and its mount point.
Mount Old HDD Partition
Once we found the partition that have data we can mount the partition with mount command and copy data to new hard disk.
In this example, let us say, data is in partition /dev/sdb2
We will mount /dev/sdb2 as /mnt/old
mkdir /mnt/old mount /dev/sdb3 /mnt/old
some times, you will need to mount different partions from OLD hard disk if the folders are different partitions. For example /home, /etc, /usr, /var - any of these are on diffrenet partition, then you need mount them to get the data copied back to new HDD.
COPY DATA FROM OLD HARD DISK TO NEW
Now we can start copying back data from the old drive
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/etc/ssl /etc/ 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 rsync -vrplogDtH /mnt/old/root/.my.cnf /root rsync -vrplogDtH /mnt/old/etc/httpd/conf/httpd.conf /etc/httpd/conf rsync -vrplogDtH /mnt/old/etc/sysconfig/network /etc/sysconfig rsync -vrplogDtH /mnt/old/etc/dovecot /etc
Copy configuration file from /etc folder from old to new HDD.
cd /mnt/old/etc rsync -vrplogDtH secondarymx valiases vfilters /etc rsync -vrplogDtH exim* proftpd* pure-ftpd* passwd* group* /etc rsync -vrplogDtH *domain* *named* wwwacct.conf cpupdate.conf /etc rsync -vrplogDtH quota.conf shadow* *rndc* ips* ipaddrpool* ssl hosts /etc rsync -vrplogDtH true* userdomains nameserverips demousers localaliases /etc
Since we copy /etc/passwd file, root password of the server will be same as in old hard disk.
You may change root password with
RUN CPANEL SCRIPTS
Update cpanel after data copied to new HDD.
/scripts/upcp /scripts/updatenow /scripts/sysup /scripts/fixeverything /scripts/eximup --force /scripts/securetmp /scripts/easyapache