Recover data from a crashed cPanel server HDD
It’s really hard if your server is crashed. In this write up I’m gonna tell you how to recover data from crashed cPanel server to a new server.
Recover data from a crashed cpanel server.
Check the disk Status
1) Get the partitions from both the drives with:
By using the command you see the disk partitions
fdisk -l /lists the partitions even its unmounted
Sample output
[[email protected] ~]# fdisk -l Disk /dev/vda: 429.5 GB, 429496729600 bytes, 838860800 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0009bf88 Device Boot Start End Blocks Id System /dev/vda1 * 2048 1026047 512000 83 Linux /dev/vda2 1026048 838860799 418917376 8e Linux LVM Disk /dev/mapper/vg_cpanel-lv_root: 426.8 GB, 426820763648 bytes, 833634304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/vg_cpanel-swap: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/vg_cpanel-lv_tmp: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
2) First check to see if there are any drives mounted, with:
df -hT
Sample Output [[email protected] ~]# [[email protected] ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/vg_cpanel-lv_root xfs 398G 219G 180G 55% / devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 417M 3.5G 11% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/vda1 xfs 497M 297M 201M 60% /boot /dev/mapper/vg_cpanel-lv_tmp xfs 1014M 54M 961M 6% /tmp tmpfs tmpfs 783M 0 783M 0% /run/user/1059
3) Let us mount the CRASHED HDD if not already mounted, with:
mount /dev/hdb3 /oldHD ls /oldHD/home
4) Run these rsync commands to move everything over:
Use rsync to copy
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
5) cd to the old etc directory:
cd /oldHD/etc
And copy some files from here:
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
6) Run cpanel fix scripts i.e
Updating software and restarting services:
/scripts/upcp /scripts/updatenow /scripts/sysup /scripts/exim4 /scripts/easyapache /scripts/securetmp /scripts/fixeverything
7) IMPORTANT ::
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
Restarting services as :
/scripts/restartsrv httpd /scripts/restartsrv cpanel /scripts/restartsrv mysql /scripts/restartsrv named /scripts/restartsrv exim
That’s all ………………!!!