Page 1 of 1

Backups / Mirroring with VirtualBox

Posted: 10. Jun 2014, 21:16
by omega1
Hi all,

I was wondering what options I have with VirtualBox regarding backing up VM's and possibly mirroring the VM's with another (backup) host machine?

AS I understand it, I have to stop any VM in order to take an accurate copy of the VM folder and then restart it. I was wondering if there was any other way to take a copy without stopping it? I think I've asked that question before, but recall the answer being no due to the VM being in constant use, etc...

Also, related to the above, is there any way I can mirror the guests I have on another server? In order to increase availability? I already have RAID drives on the hsot machine, but was wondering if I could mirror the VM's in the same way?

I'd appreciate any comments / advice / suggestions on the above.

Thank you in advance.

Re: Backups / Mirroring with VirtualBox

Posted: 11. Jun 2014, 14:42
by scottgus1
Greetings, Omega1!
As I understand, you are correct in that a simple and sure copy of the guest Virtualbox files and virtual disk requires the guest to be shut down.

Some folks have come up with a way to take a snapshot of the guest while it is running, which releases the base virtual disk to be copied, then when the copy is done, undo the snapshot. This routine leaves the backup of the guest in a running state with unique processor information, which makes the restore a riskier prospect, having to come back from what is essentially the same as a power outage while the guest was running. And if the host has changed, the processor is likely to have changed, possibly causing further difficulties in restoring.

Using backup software within the guest allows for a hot backup.

One could keep a cold, guest-shut-down-properly backup on the other server and then copy within-the-guest backups to the other server, for a reasonably quick restore on the other server, as in, turn on the secondary guest registered to the other server after the primary guest fails, then restore the backups to bring the secondary guest close to up-to-date.

I suppose it would be possible to attach two virtual disks to a guest, one on the local server and one on a shared folder on another server, then mirror the drives using software raid within the guest. I did just try to attach a vdi saved on a mapped network share to an XP guest on my Virtualbox 4.2.16 host and the guest booted up and recognized and wrote to the new drive. Only thing I could see to make it not work might be the network speed, which would have to be wicked fast, probably much faster than gigabit.

Re: Backups / Mirroring with VirtualBox

Posted: 11. Jun 2014, 21:17
by noteirak
Let's be clear : there will never be a magical way to take hot/live backup of a full system. There are ways to interacts with some compliant applications to perform the so-called "consistant" backup but it is up to the application to support it or not.
If you only think at the VM level, there are three ways of doing it :

1. Don't do anything special, just copy the VM files while it's running. It's also the best way to screw up your backup and not be able to restore anything.
2. Take a snapshot of the running VM, copy the VM files, remove the snapshot. You'll get a system which is in a state like you pulled the power cable - some applications don't like it.
3. Stop the VM, take your backup, restart the VM. You get an actual consistant backup.

In the end, it all depends on your requirements. Personally, I tend to do solution #2 during the week and #3 during the weekend when I can turn off some critical machines.
I had to restore several times from backups in #2 and #3 and never had an issue. But what is true for me is not always true for you.

If you can accept downtime, go with #3 at a regular interval. Else go for #2.
You can also go for #2 once a week and run a backup from within the VM in an application-aware scenario per example. This way you keep your VM data in case you get a big lost/crash/corruption, but you also have only the application data to recover from small problems where the VM & OS is fine.

Finally, Virtualbox doesn't have any special feature for backup or mirroring, so you'll have to look at other options.

Re: Backups / Mirroring with VirtualBox

Posted: 11. Jun 2014, 23:36
by omega1
Interesting, thanks for the comments!

Could you explain the steps you take to take the copy of the snapshot? At the moment I am shutting them down and copying the folder, but at 150GB each, this takes time to copy before I can restart them.

Thanks.

Re: Backups / Mirroring with VirtualBox

Posted: 12. Jun 2014, 00:18
by Perryg
Typically I only keep a backup of the data from the guest, on a daily basis using the backup recommended for the type of guest. (usually rsync)

I copy the complete folder set at creation and only replace it when I do an update. (maybe once a month during a normal maintenance window) All of this is due to considering how you need to create the guest before hand like creating a second virtual drive for the data to reside on or a separate drive/partition for the home folder on a Linux setup.

I have tested this and the actual down time for a catastrophic failure was less than 30 minutes with minimal data loss ( data that had not been backed up yet ) and no changes in the way the guest OS was set up or used. In fact if the reason for the loss was due to OS failure or drive failure and not on the data drive or partition there was/is no loss of data.

Most people IMHO try to make everything fit in a single environment when they would be better served if it was in a lot of single containers. Much easier to manage in the long run.

Re: Backups / Mirroring with VirtualBox

Posted: 12. Jun 2014, 02:37
by noteirak
My steps :
1. copy the .vbox to .vbox.bk to not be bothered by the backup snapshot when restoring
2. take live snapshot
3. copy the VM folder
4. remove snapshot