On Xen Server 6.1, to backup my VMs, I use a script based on the following tools:
xe vm-list
to build a list of the VMs to backupxe vm-snapshot
to take a snapshot of the VMsxe template-param-set is-a-template=false ha-always-run=false
to convert the snapshot to a VMxe vm-export vm=uuid_of_this_new_vm filename=|ssh ..... "cat > /path/backup.xva"
–> To send the export to my backup server without to store it locallyxe vm-uninstall
I'd like to use sshfs to mount my remote backup server on my Xen host. But sshfs is not available in the Xen distribution or the default repository (XenServer 6.1.0 updates).
I have a few possibilities to install sshfs on my Xen host:
- I add a repo that contains sshfs. I think it could cause me troubles later. It's not supported by Xen and I prefer to let the host config mostly unchanged
- I could take a tarball and install it in a directory apart
- or I take a RPM and install it apart
OR I find a way to pipe a remote ssh command into xe vm-import
like I do for the export. I tested a lot of things but nothing that works
What would be the best solution in your opinion?
Best Answer
Although this is an old question, I have just figured this one out myself.
First.. what DOES NOT WORK (All tested on XenServer 6.5):
xe-import filename=/dev/stdin
does not work.. at all. It does not matter whether you do:So, what I have found is that there is no way to import from a stream, it has to be a real filesystem of some sort. Apparently this used to work, but it doesn't now. My guess is that xenserver wants to seek.
(If anyone can spot a flaw in my attempts and prove me wrong, I'd be very grateful).
So, yes, my conclusion is that you must use a remote filesystem, and we know that NFS works for this, because we've used it.. but decided on sshfs for simplicity. Here is how I installed sshfs on XenServer 6.5:
Ok now to restore from an export on another machine:
Oh, and I should add.. I tried installing the xenxerver tools on our backup server.. it does not work either. Sure, you can execute commands and it all looks great. But
filename=/dev/stdin
still does not work, NOR DOESfilename=/path/to/myexport.xva
. It just hangs or starts importing then fails in weird ways.So that's importing.. but what about exporting? Using the xenserver tools remotely installed:
xe vm-export uuid=the-vm-uuid filename= -s xenhost.my.domain -u root -pwf password_file
This DOES export to stdout. But it's a bit unclear as to whether those exports will always import successfully. I experienced a couple of failures and some successes. SO decided against using remote tools at all.. but do it via ssh instead:
IT WORKS!
The upshot of this is that, with our backup system (Bareos) it is possible to do a backup via ssh directly into the backup software, without having to do an export to a temporary file first. But to do the restore, it is necessary to restore the xva to a temporary storage first, then mount on the xenhost with sshfs, then vm-import. I am sad that we can't stream both ways.. hopefully this will be fixed in xe some time.
Hope this helps some people.. it took a good amount of trial and error to test all the possibilities :)