Wednesday, May 30, 2012

Using dump/restore command do the backup and restore whole CentOS/RedHat/Fedore/SUSE/Ubuntu.


Using dump/restore command do the backup and restore whole CentOS/RedHat/Fedore/SUSE/Ubuntu.

http://dump.sourceforge.net/isdumpdeprecated.html

# cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot1            /boot                   ext3    defaults        1 2
LABEL=/data             /data                   ext3    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda5         swap                    swap    defaults        0 0


# fdisk -l
   Device Boot    Start      End    Blocks      Id  System
/dev/sda1 *           1       13    104391      83  Linux
/dev/sda2            14      1925   15358140    83  Linux
/dev/sda3          1926      3200   10241437+   83  Linux
/dev/sda4          3201      4864   13366080    5   Extended
/dev/sda5          3201      3391   1534176     82  Linux swap / Solaris


# dump -0uf - /dev/sda1 | ssh root@192.168.0.14 dd of=/tmp/sda1.dump
# dump -0uf - /dev/sda2 | ssh root@192.168.0.14 dd of=/tmp/sda2.dump
# dump -0uf - /dev/sda3 | ssh root@192.168.0.14 dd of=/tmp/sda3.dump
# dump -0uf - /dev/sda4 | ssh root@192.168.0.14 dd of=/tmp/sda4.dump
# dump -0uf - /dev/sda5 | ssh root@192.168.0.14 dd of=/tmp/sda5.dump

Restore the data

# restore -rf /sda1.dump
# restore -rf /sda2.dump
# restore -rf /sda3.dump
# restore -rf /sda4.dump
# restore -rf /sda5.dump

Live CD/rescue mode first and use fdisk to create partitions and give ip address

Create a partitions on new disk

Fdisk /dev/sda

format sda1/sda2/sda3/sda5 by using the mkfs command
# mkfs.ext3 /dev/sda1
# mkfs.ext3 /dev/sda2
# mkfs.ext3 /dev/sda3
# mkfs.ext3 /dev/sda4
# mkfs.ext3 /dev/sda5

Re-label all the partitions
# e2label /dev/sda1 /boot1
# e2label /dev/sda2 /
# e2label /dev/sda3 /data
# mkswap -L SWAP-sda5 /dev/sda5

login into 192.168.0.187, and restore sda1 from a remote 192.168.0.14 sda1.dump

# ssh 192.168.0.187 "cd /mnt/sda1 && RSH=/usr/bin/ssh restore -r -f 192.168.0.14:/tmp/sda1.dump"

Please run grub-install in rescue mode first. Install grub on /dev/sda1*

No comments: