Backup while running?

Discussions related to using VirtualBox on Linux hosts.
Locked
jmar83_the2nd
Posts: 341
Joined: 9. Mar 2012, 00:14

Backup while running?

Post by jmar83_the2nd »

Is it possible to create some backups of a VirtualBox VM while running?

The system i want to use is Debian 10.0 with its VirtualBox package.

Thank you for your feedbacks.
regards, jan
andyp73
Volunteer
Posts: 1631
Joined: 25. May 2010, 23:48
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Assorted Linux, Windows Server 2012, DOS, Windows 10, BIOS/UEFI emulation

Re: Backup while running?

Post by andyp73 »

The general recommendation is to backup important files within the guest in the same way you would backup important files on a physical computer. You should then also backup the VM folder on the host following the advice in Moving a VM but interpreted as "Backing up a VM" but this has to be done with the guest powered off.

I have a script that runs as a cron job on my Linux host that powers off the guest, copies the folder and then restarts the guest. It starts running at midnight when nobody is around to notice or care!

I think there may be mechanisms that will allow for a backup of the whole guest to be taken whilst it is running but I've never been confident enough to give it a try.

-Andy.
My crystal ball is currently broken. If you want assistance you are going to have to give me all of the necessary information.
Please don't ask me to do your homework for you, I have more than enough of my own things to do.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Backup while running?

Post by socratis »

andyp73 wrote:I think there may be mechanisms that will allow for a backup of the whole guest to be taken whilst it is running but I've never been confident enough to give it a try.
We had a good chat about this several months ago, but alas on IRC. Sometimes I hate that, because IRC has a really short memory. :(

I might look into the transcripts and see what I come up with, might make a FAQ out of it. It was my idea that worked at the end, but I'm like IRC... Short memory. :)

If I find anything, I'll let you know...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
jmar83_the2nd
Posts: 341
Joined: 9. Mar 2012, 00:14

Re: Backup while running?

Post by jmar83_the2nd »

ok thx
regards, jan
Guideloom
Posts: 29
Joined: 5. Sep 2018, 18:42

Re: Backup while running?

Post by Guideloom »

I've looked at this in many many different ways. I've never been able to get it to work, nor do I know of any way to do it.
The only way to backup a "running" VM (not including using a backup running in the VM guest OS) is to put the VM into savestate. Otherwise you must power it off.

I have a backup script that does all the heavy lifting. We've been using it to backup ~25 VMs and it's been working great.
See this post for additional info: viewtopic.php?f=7&t=93512
socratis wrote:I might look into the transcripts and see what I come up with, might make a FAQ out of it. It was my idea that worked at the end, but I'm like IRC... Short memory. :)
What did you do? Every single possible combination I've tries fails. You can't even clone a backup of a snapshot of a running VM, it fails. PLEASE share! :)
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Backup while running?

Post by fth0 »

Just a thought experiment:

What would happen, if you
  • Create a snapshot from the running VM and backup the VM folder.
  • Restore the VM folder and restore the snapshot before starting the VM.
Obviously, you would lose the changes made after the snapshot. And apart from that?
Last edited by fth0 on 16. Nov 2021, 18:58, edited 1 time in total.
jmar83_the2nd
Posts: 341
Joined: 9. Mar 2012, 00:14

Re: Backup while running?

Post by jmar83_the2nd »

Now i changed to Windows 10 as host OS, because there was a lot of problems with Debian. So i can't use https://github.com/guideloom/vbbu

Then i need to put it in a save state, and after that i can create a backup so i saw also on VirtualBox on Windows 10. Then i will try that (hope it's the correct way) asap.
regards, jan
jmar83_the2nd
Posts: 341
Joined: 9. Mar 2012, 00:14

Re: Backup while running?

Post by jmar83_the2nd »

Yes, save state seems to work - more or less...

When i do a snapshot, while doing that the VM will be put in a save state, then revert to running state again. I don't had problems in the GUI (phpvirtualbox) but the SSH connection to the VM has problems sometime..
regards, jan
wadih
Posts: 1
Joined: 21. Jan 2022, 21:26

Re: Backup while running?

Post by wadih »

It's possible to take a snapshot, then you can clone the snapshot, all without having shutdown the machine.
2022-01-21_14-29.png
2022-01-21_14-29.png (40.45 KiB) Viewed 5704 times
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Backup while running?

Post by scottgus1 »

@wadih, thanks for relating your idea!

However, using a snapshot to do a running-VM backup is a bad idea. The VM OS does not know it is being backed up, so it does not prepare open databases, shadow copies, caches, pending disk writes etc. and the data is all corrupted and unreliable. Then when the backup is restored, the OS acts as if it was powered off unceremoniously, with all power-loss troubles that may come about.

Backup routines involving a snapshot are bad things. Sure they may restore, but the data is broken and you will find a corruption somewhere if you know where to look. Most folks don't know where to look, so they press on with corrupted data.

The best way to back up a running VM is with 3rd-party backup software inside the VM OS, compatible with the services the OS is providing, and saved out of the VM over a network shared folder to a different physical disk somewhere.

Since this topic is old, I'll lock it and encourage further posters to start a new topic.
Locked