In my last job I was responsible not only for for Oracle databases asd DBA but for Xen maintenance too. I was used to backuping all my VMs using dd and pbzip2. The main command was something like - from dom0 -
# 1. Create a LVM snapshot
lvcreate -s -n <name_of_the_snapshot> -L<size>G /dev/xenvg/<name_of_LVM>
# 2. Backuping VM
dd if=/dev/xenvg/<name_of_the_snapshot> | pbzip2 -c -z -m1024 -v -p3 > /path/to/<name_of_backup_VM>.img.bz2
Today for personal reason, I will like to test a new tool: fsarchiver

1. fsarchiver - informations

For more details, have a look on the main Web site : http://www.fsarchiver.org/Main_Page

2. fsarchiver - installation

  • Prerequisites for Debian Squeeze
    apt-get update
    apt-get install zlib1g-dev libssl-dev libbz2-dev liblzo2-dev e2fslibs-dev attr-dev libssl-dev libblkid-dev uuid-dev  libgcrypt11-dev
  • lzma depends on xz
    wget http://tukaani.org/xz/xz-5.0.3.tar.bz2
    tar xjf xz-5.0.3.tar.bz2 
    cd xz-5.0.3/
    ./configure 
    make -j4
    make check
    make install && ldconfig
  • farchiver

    Download the last sources from http://sourceforge.net/projects/fsarchiver/files/fsarchiver-src/ then

    tar xvf fsarchiver-0.6.12.tar.gz 
    cd fsarchiver-0.6.12/
    ./configure 
    make -j4
    make install && ldconfig

3. Test for backups

I've got a domU mercury-xen01. This is a Linux PVHVM - I used it for my tests for VGA PassThrough -. This domU relies on LVM: /dev/xenvg/mercury-xen01-disk-1

3.1 Make a snapshot before testing

  1. lvcreate -s -n mercury-xen01-disk-1.snapshot -L30G  /dev/xenvg/mercury-xen01-disk-1
    
  2. Now we can use kpart
    root@mercury:~# kpartx -va /dev/xenvg/mercury-xen01-disk-1
    add map xenvg-mercury--xen01--disk--1p1 (253:14): 0 402339840 linear /dev/xenvg/mercury-xen01-disk-1 2048
    add map xenvg-mercury--xen01--disk--1p2 (253:15): 0 17084418 linear /dev/xenvg/mercury-xen01-disk-1 402343934
    add map xenvg-mercury--xen01--disk--1p5 : 0 17084416 linear 253:15 2
    

3.2 Backup with default compression level (-z3 / gzip)

This is the default compression level (equivalent to gzip -6 ) First have a look http://www.fsarchiver.org/Compression
fsarchiver savefs -j4 -v -o /opt/montage/mercury-xen01-disk-1_backup_2012-02-21.fsa /dev/mapper/xenvg-mercury--xen01--disk--1p1
For information about archive
root@mercury:~# fsarchiver archinfo /opt/montage/mercury-xen01-disk-1_backup_2012-02-21.fsa
====================== archive information ======================
Archive type: 			filesystems
Filesystems count: 		1
Archive id: 			4f4c603b
Archive file format: 		FsArCh_002
Archive created with: 		0.6.12
Archive creation date: 		2012-02-22_01-59-35
Archive label: 			
Minimum fsarchiver version:	0.6.4.0
Compression level: 		3 (gzip level 6)
Encryption algorithm: 		none

===================== filesystem information ====================
Filesystem id in archive: 	0
Filesystem format: 		ext4
Filesystem label: 		
Filesystem uuid: 		be744358-3672-4a94-818d-c09c178b01d2
Original device: 		/dev/mapper/xenvg-mercury--xen01--disk--1p1
Original filesystem size: 	188.84 GB (202765496320 bytes)
Space used in filesystem: 	10.05 GB (10787442688 bytes)
Archive size
root@mercury:~# du -hs /opt/montage/mercury-xen01-disk-1_backup_2012-02-21.fsa
4,1G	/opt/montage/mercury-xen01-disk-1_backup_2012-02-21.fsa

3.3 Backup with high compression level (-z9 / lzma)

Keep in mind
  • [+]: smaller archive, better decompression time
  • [-]: takes more time to generate archive
fsarchiver savefs -j4 -v -o -z9 /opt/montage/mercury-xen01-disk-1_backup_2012-02-21_using_lzma.fsa /dev/mapper/xenvg-mercury--xen01--disk--1p1
For informations about archive
root@mercury:~# fsarchiver archinfo /opt/montage/mercury-xen01-disk-1_backup_2012-02-21_using_lzma.fsa
====================== archive information ======================
Archive type: 			filesystems
Filesystems count: 		1
Archive id: 			4f4afe30
Archive file format: 		FsArCh_002
Archive created with: 		0.6.12
Archive creation date: 		2012-02-22_02-10-24
Archive label: 			
Minimum fsarchiver version:	0.6.4.0
Compression level: 		9 (lzma level 9)
Encryption algorithm: 		none

===================== filesystem information ====================
Filesystem id in archive: 	0
Filesystem format: 		ext4
Filesystem label: 		
Filesystem uuid: 		be744358-3672-4a94-818d-c09c178b01d2
Original device: 		/dev/mapper/xenvg-mercury--xen01--disk--1p1
Original filesystem size: 	188.84 GB (202765496320 bytes)
Space used in filesystem: 	10.05 GB (10787442688 bytes)
Archive size
root@mercury:~# du -hs /opt/montage/mercury-xen01-disk-1_backup_2012-02-21_using_lzma.fsa
3,3G	/opt/montage/mercury-xen01-disk-1_backup_2012-02-21_using_lzma.fsa

4. Test for restore

To be completed!