[Linux-Cpanel] Restoring data from failure HDD

Posted by cikul | Posted in cpanel, Linux | Posted on 06-06-2012-05-2008

0

I have experience with primary hard disk failed on my Cpanel Server, and i asked datacenter to reloaded OS in a new Hard Disk and mounted old Hard Disk as secondary for copying data back to new hard disk.

To copy data from failure hdd first, you must mount old hdd

# mkdir /mnt/old
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1.5G 288M 1.1G 21% /
/dev/sda7 116G 796M 110G 1% /home
/dev/sda6 494M 20M 449M 5% /tmp
/dev/sda3 9.5G 2.1G 7.0G 23% /usr
/dev/sda2 16G 340M 15G 3% /var
tmpfs 949M 0 949M 0% /dev/shm

# fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 191 1534176 83 Linux
/dev/sda2 192 2231 16386300 83 Linux
/dev/sda3 2232 3506 10241437+ 83 Linux
/dev/sda4 3507 19457 128126407+ 5 Extended
/dev/sda5 3507 3767 2096451 82 Linux swap / Solaris
/dev/sda6 3768 3832 522081 83 Linux
/dev/sda7 3833 19457 125507781 83 Linux

Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 191 1534176 83 Linux
/dev/sdb2 192 2231 16386300 83 Linux
/dev/sdb3 2232 3506 10241437+ 83 Linux
/dev/sdb4 3507 19457 128126407+ 5 Extended
/dev/sdb5 3507 3767 2096451 82 Linux swap / Solaris
/dev/sdb6 3768 3832 522081 83 Linux
/dev/sdb7 3833 19457 125507781 83 Linux

# mount /dev/sdb1 /mnt/old/
# mount /dev/sdb2 /mnt/old/var/
# mount /dev/sdb3 /mnt/old/usr/
# mount /dev/sdb6 /mnt/old/tmp/
# mount /dev/sdb7 /mnt/old/home/
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1.5G 288M 1.1G 21% /
/dev/sda7 116G 796M 110G 1% /home
/dev/sda6 494M 20M 449M 5% /tmp
/dev/sda3 9.5G 2.1G 7.0G 23% /usr
/dev/sda2 16G 340M 15G 3% /var
tmpfs 949M 0 949M 0% /dev/shm
/dev/sdb1 1.5G 349M 1.1G 26% /mnt/old
/dev/sdb2 16G 2.3G 13G 16% /mnt/old/var
/dev/sdb3 9.5G 3.4G 5.7G 38% /mnt/old/usr
/dev/sdb6 494M 12M 457M 3% /mnt/old/tmp
/dev/sdb7 116G 9.2G 101G 9% /mnt/old/home

Now we can start copying data from old hdd to new hdd

# 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

# rsync -vrplogDtH /mnt/old/var/lib/mysql /var/lib
# rsync -vrplogDtH /mnt/old/var/cpanel /var
# rsync -vrplogDtH /mnt/old/usr/local/apache/conf /usr/local/apache
# rsync -vrplogDtH /mnt/old/usr/local/apache/domlogs /usr/local/apache
# rsync -vrplogDtH /mnt/old/usr/local/frontpage /usr/local
# rsync -vrplogDtH /mnt/old/var/named /var
# rsync -vrplogDtH /mnt/old/var/ssl /var
# rsync -vrplogDtH /mnt/old/var/spool/cron /var/spool
# rsync -vrplogDtH /mnt/old/usr/share/ssl /usr/share
# rsync -vrplogDtH /mnt/old/etc/vfilters /etc
# rsync -vrplogDtH /mnt/old/etc/proftpd /etc
# rsync -vrplogDtH /mnt/old/etc/vmail /etc
# rsync -vrplogDtH /mnt/old/home/* /home
# rsync -vrplogDtH /mnt/old/usr/local/cpanel /usr/local
# 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/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

Copy configuration file from /etc folder from old to new HDD.

# 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 hosts userdomains trueuserdomains trueuserowners nameserverips cpupdate.conf demousers localaliases /etc

Update cpanel after data copied to new HDD.

# /scripts/upcp
# /scripts/updatenow
# /scripts/sysup
# /scripts/fixeverything
# /scripts/eximup --force
# /scripts/securetmp
# /scripts/easyapache
# /scripts/restartsrv httpd
# /scripts/restartsrv cpanel
# /scripts/restartsrv mysql
# /scripts/restartsrv named
# /scripts/restartsrv exim

To Fix Package :

for i in $(cat /etc/userdomains | awk -F: '{print $2}'); do touch /var/cpanel/users/$i; /scripts/updateuserdomains; done

Write a comment

*