11 May 2011

How to backup LIVE vms in XENserver to USB Disk

Ever wanted to do full backups of your vms running in xenserver free edition?
Sure you can export them as backup, but in order to do so you would need to power them down.
After some digging around in the command and reading several forum threads etc...
Now I've been using this method for quite a while and it has proven working and successful.

First of all we will need to make the USB disk useable to the system, in order to do so connect the disk to the server and log on to the server using the local console or remote shell

To view the disks connected to the system enter
fdisk -l (yes that's an L)

Then see if your disk is listed , probably something like /dev/sda(but could be sdb/c/etc...)

Now we must partition the disk.
fdisk -l (yes L) /dev/sda
if there are any partitions , delete them by pressing d

Now press n for new partition, then p for primary
Then press w to save changes

So now we must format the partition so there is a valid filesystem for the system to use.
mkfs.ext3 /dev/sda1  (this may take a while depending on the disk size)

Now that we have a valid and useable disk to perform our backups on, it's time to make the disk available to the system.

to do so:
mkdir /mnt/<xenbackupfoldernameyoulike>
mount /dev/sda1 /mnt/<xednbackupfolderyoucreated>
From here on the disk is ready to be used, so we'll skip to the fun part, the actual backups.

To fully backup(export) a live VM we need to snapshot-->convert snapshot to "vm"-->export the "vm" -->cleanup

1 Snapshot the machine, this can be done by the shell or xencenter, whatever you prefer.

The following is all SHELL!!!

2 Identify the snapshot you just made:
   xe snapshot-list
   this will give you a list of snapshots, note the UUID for the needed snapshot.

3 Marking the snapshot as a "vm"
   xe snapshot-param-set is-a-template=false uuid=<UUID of the snapshot>

4 Exporting the vm
   xe vm-export vm=<name of the snapshot you converted> filename=/mnt/xenbackupfolder/filenameyoulike.xva


The export will take a while, depending on the size of the vm.
You can monitor the progress in xencenter by selecting your xen host in the left pane and then clicking the "log" tab.

after the export is complete you may delete the snapshot.

2 comments:

Ajay Kamble said...

Hi!,

Thanks for the guide.

I backup the xenserver.

Can you guide me how to restore it?

Thanks,

Unknown said...

VMS is very reliable and powerful software that access videos which are stored on cameras.
VMS