Backup the live Ubuntu system by following the below steps:
Use df -h command to figure out what is the logical volume where the root file system is on. Also look into /dev directory for the logical volumes. In the example below, the logical volume that holds the entire system is /dev/vg00/vg00-lv01
Only do this once when the system is clean:
1. Create a logical volume from a volume group (vg01) which will store the backup:
lvcreate -L 40G -n space vg01
2. Create the file system on the new logical volume:
mkfs -t ext4 /dev/vg01/space
3. Create snapshot of the root logical volume:
lvcreate --size 6G -s -n cleansystem /dev/vg00/vg00-lv01
4. Create a directory to mount the logical volume:
mkdir /space
mount /dev/vg01/space /space mkdir -p /space/snap /space/backup
5. Mount snapshot and save everything
mount /dev/vg00/cleansystem /space/snap
cd /space/snap
tar -pczvf /space/backup/cleansystem.tar.gz *
umount /space/snap
lvremove /dev/vg00/cleansystem
After these steps, a tar.gz file named cleansystem.tar.gz should be produced in /space/backup directory. This is the file should be kept for restore later.
Restore the Ubuntu sytem by following the below steps:
The follow steps are to recover the system from the saved tar.gz in /space/backup directory, assume that the logical volume which contains the backup tar.gz file has been mounted on /space.
lvcreate —size 20G -s -n resetpoint /dev/vg00/vg00-lv01
mount /dev/vg00/resetpoint /space/snap
cd /space/snap
rm -r -f *
tar -xvf /space/backup/cleansystem.tar.gz
umount /space/snap
lvconvert —merge /dev/vg00/resetpoint
No comments:
Post a Comment