RHEL6 Advanced Backup Recovery

RHEL6 Advanced Backup Recovery

preview
This article is a abstract example. Because the situation is complex.
Indeed,I was lazy to make snapshot.    

1)backup all your files.
1@@@@mount a health filesystem using rescue mode
@@@before every thing,you could add a disk.
@@@Assume that we add a disk to your filesystem, it's name is /dev/sdb 

skip       @@@do not mount all your filesystem.

#fdisk /dev/sdb        @@@format a partiton. assure you have enough space.
#mkfs.ext4 /dev/sdb1

@@@create necessary directory.
#mkdir /partition1
#mkdir /partition2
#mkdir /partition3 @@@it's up to your partition information  
#mkdir /target     @@@it's up to your partition information too.

@@@mount necessary disk and partitions using directory you created.
#mount /dev/sdb1  /target
#mount /dev/sda1  /partition1
#mount /dev/sda2  /partition2
#mount /dev/sda3  /partition3 @@@assume your FS in these partitions.

@@@copy all your files to partition /dev/sdb1
#cd /target
#tar -zcvf part1.tgz /partition1
#tar -zcvf part2.tgz /partition2
#tar -zcvf part3.tgz /partition3





2)recovery
1@@@@create partitions and restore all files to disk.
@@@mount whole target disk using rescue mode
@@@referencing Rescue 

skip

@@@make partition on your target disk.
#fdisk /dev/vda     @@@you create three partition
#mkfs.ext4 /dev/vda1  @@@Maybe you could using mkfs.xfs
#mkfs.ext4 /dev/vda2
#mkfs.ext4 /dev/vda3
#mkswpan /dev/vda4  @@@you need add a swap partition. !!!
@@@Note:
@@@Generlly swap partition is equal to 1.5 times of your memory.


@@@create directories 
#mkdir /source
#mkdir /t_boot_1 
#mkdir /t_root_2 
#mkdir /t_var_3

@@@mount your target partition to your directories.
#mount /dev/vda1 /t_boot_1
#mount /dev/vda2 /t_root_2
#mount /dev/vda3 /t_var_3

@@@release all packages to these partition. 
#cd /t_boot_1    #tar -zxvf /source/part1.tgz 
#cd /t_root_2    #tar -zxvf /source/part2.tgz 
#cd /t_var_3     #tar -zxvf /source/part3.tgz

@@@
#reboot





3@@@@restorce the filesystem.
@@@after reboot. Start using rescue mode too.
@@@Select “continue” 


@@@
@@@First,recover /etc/fstab
@@@
#chroot /mnt/sysimage
#vim /etc/fstab     @@@modify the /etc/fstab as your wish.
####begin#########################################
/dev/vda1    /boot          ext4    defaults        0 0

/dev/vda2    /              ext4    defaults        1 2

/dev/vda3    /var           ext4    defaults        1 2

/dev/vda4    swap           swap    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

######end#########################################


@@@
@@@Second,recover initrd
@@@
@@@if your kernel is missing, you could do as below:
@@@#cd /
@@@#mkdir /source
@@@#mount -o nolock 192.168.0.63:/var/ftp/pub  /source
@@@#rpm -ivh  --force kernel-2.6.32-220.el6.x86_64.rpm --root /mnt/sysimage

#chroot /mnt/sysimage
#cat /boot/grub/grub.conf   @@@check the initramfs-xxxx.img
#cd /boot
#mkinitrd initramfs-2.6.32-220.el6.x86_64.img  2.6.32-220.el6.x86_64



@@@
@@@Third,recover gurb
@@@
#chroot /mnt/sysimage 
#grub-install --force-lba “(hd0)”  
@@@or #grub-install –force-lba /dev/vda 
#reboot 

本文出自 “Oracle+Linux=>Majesty” 博客,谢绝转载!

你可能感兴趣的:(职场,backup,休闲,RHEL6,recovery)