Useful Commands for Backing up Virtual Machine Image


The following commands are frequently used for VM image backup.

1. To back up a snapshot of an LVM volume group to another LVM volume group
# lvcreate -L20480 -s -n 'vm-10.0.0.123-snapshot' /dev/vg_xen/vm-10.0.0.123

2. To back up a snapshot of an LVM volume group to a file image
# dd if=/dev/vg_xen/vm-10.1.1.229 of=/lhome/xen/vm-10.1.1.229-snapshot/vm-10.1.1.229.img bs=1k

3. To allocate an image disk from an LVM volume
# dd if=/dev/zero of=/lhome/xen/f12install/vmdisk0 bs=1k seek=20480k count=1

4. To transfer a remote file image to local machine
# scp -c arcfour root@10.0.0.10:/lhome/xen-image/vm-10.0.0.123-lv.img /lhome/xen-image/

5. To create a tar package
# tar -cvf package.tar 'folder'

6. To expand a tar package
# tar -xvf package.tar -C 'expand-directory'

7. To compress a folder into tar.gz file
# tar -cvzf package.tar.gz 'folder'

8. To expand a gz file
# tar -xvzf package.tar.gz -C 'expand-directory'

9. To compress a folder into tar.bz2 file
# tar -cvjf package.tar.bz2 'folder'

10. To expand a bz2 file
# tar -xvjf package.tar.bz2 -C 'expand-directory'

11. To compress a folder into zip file
# zip -r package.zip 'folder'

12. To expand a zip file
# unzip package.zip

Free Web Hosting