VM Backup with Xen Orchestra

Jul 28, 2014

UPDATE: we are now supporting Rolling snapshots, Full VM backups and even Delta backup for XenServer! Read our blog post about XenServer incremental backup with Xen Orchestra.

As you may already know, we planned to integrate backups directly in Xen Orchestra: this feature is in our current road map.

The goal is to provide a simple interface to select, plan and automatize all your VMs backups. But, until its done, one of our clients needs quickly a way to snapshot all its running VMs in one command. Remember this diagram?

xo-arch

Well, why not connect a kind of "client" to send order directly to "xo-server" to automatize all this stuff? After all, we had a unique entry point for all XenServer via the core of XO.

That's how "xo-backup" (as a plug in) is born in less than 2 days  and 200 lines of code! Let's see the architecture diagram with this new client:

image

As you can see, "xo-backup" is a completely standalone client, it could be executed on any machine you like, even not on the same box running "xo-server". For example, it can run on your backup server, dedicated to that kind of tasks.

How it works

Let's take a real and simple example. I will use "xo-backup" on my PC at home, to start a backup on the existing demo instance of Xen Orchestra (running in a data-center), itself connected to our small lab in our offices:

xo-backup (home) -> xo (datacenter) -> xenserver (office)

On one running VM, I've got no snapshot:

nosnap

Here is a simple example of this client:

$ xo-backup --max-snapshots 2 --user admin@vates.fr https://dev1.vates.fr/api/
[?] Password: ********
✔︎ vm1 snapshotted
✔︎ vm2 snapshotted
✔︎ vm3 snapshotted
✔︎ vm4 snapshotted

As you can see, we created a snapshot on each of this VM. If I go on a VM screen in XO, now I can see:

onesnap

Great! Now  I can revert to this snapshot in two clicks, also remove or rename it if I want:

onesnapedit

Or, but let's try to restart "xo-backup", using exactly the same command. The result is now:

twosnap

Remember the "--max-snapshots 2" parameter in the command line? What if I choose to start a new "xo-backup" now?

$ xo-backup --max-snapshots 2 --user admin@vates.fr https://dev1.vates.fr/api/
 [?] Password: ********
 ✔︎ vm1 snapshotted
 ✔︎ vm1 old snapshot deleted auto-2014-07-27T09:34:49.434Z

The oldest one is automatically removed! That's why you can use this script directly in a Cron job (like the example given here). In this way, you made a snapshot rotation, allowing a rollback D-1 etc.

Wait! If I made my own snapshot manually between automated "xo-backup" execution?

No problem! Our client filters automatically on the "auto-" prefix present in your snapshot name. If you manually create one, with for example "snap_before_update" name, it will NOT be removed by "xo-backup"! That's why you can continue to use snapshots manually in parallel of "xo-backup".

... wait! (again). Snapshots are NOT backups!

You're totally right! That's because "xo-backup" is just at its first version. Our next objective is to allow full exports of VM, *.xva files on your local disk, or any accessible mount on your system.

This feature will come with parameters to target only VM you like (or all, or with a filter you give). We choose to start with snapshots, because that's the first step allowing full export of a running VM: we'll export its fresh snapshot during its execution (because you can't export directly a running VM).

Thanks to our sponsor

This client was sponsored by OOWorx. Thanks to them for helping XO to be better!

Remember: you can do the same and sponsor a feature you need! Contact us for me details.

Olivier Lambert

Vates CEO & co-founder, Xen Orchestra and XCP-ng project creator. Enthusiast entrepreneur and Open Source advocate. A very happy Finnish Lapphund owner.