Backup Tool for VB VMs

Discussions related to using VirtualBox on other (unsupported) hosts like FreeBSD.
Post Reply
testit
Posts: 28
Joined: 31. Jul 2011, 14:26
Primary OS: FreeBSD
VBox Version: OSE other
Guest OSses: bisher: keine

Backup Tool for VB VMs

Post by testit »

Hi,

I would like to regularly back up all VMS running under VirtualBox under FreeBSD, as it could happen that important files such as .vbox, .vhd and the snapshots are compromised.

Is there a special backup tool for VirtualBox or is it sufficient to simply back up the above-mentioned files "normally" as part of the usual backups?

Thanks in advance and kind regards
testit
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Backup Tool for VB VMs

Post by scottgus1 »

Virtualbox does not come with a backup tool. That would be an interesting additional feature.

A full host OS folder copy of the completely-shut-down (not save-stated or still running) VM folder with all files therein, as well as the VM's disk files if they are not in the VM's folder, serves as a complete backup of the VM. You can FC file-compare the backup to confirm the copy. If the original is lost, move a copy of the backup back to the original location and the VM will be ready again. The copy can be used on a different host PC too, just by registering the VM's .vbox file.

If you have to back up the VM while the VM is running, use 3rd-party backup software inside the VM OS that is compatible with the OS and the services inside the OS to make a disk image saved out to a real shared folder over the network on the host OS or LAN.

Any "backup" routine that you may come across that runs on the host OS and claims to be able to back up a running VM is snake oil, leaving the "backed-up" VM in the same state as if you just unceremoniously killed power on the VM then copied it. Dirty databases, unfinished files, lost data.
testit
Posts: 28
Joined: 31. Jul 2011, 14:26
Primary OS: FreeBSD
VBox Version: OSE other
Guest OSses: bisher: keine

Re: Backup Tool for VB VMs

Post by testit »

Thank you very much,

I had already thought that the problem would be that the VM should first be shut down completely before it is backed up via the host's backup system. Most modern backup systems allow commands to be issued BEFORE and AFTER the backup task is executed.

Therefore, my "problem" should probably be solvable by issuing a shell command immediately before the backup that shuts down the VM (VBoxManage controlvm <VM name> acpipowerbutton) and queries whether the VM has already been completely shut down, in order to then restart the VM after the backup with a shell command (VBoxManage controlvm <VM name> poweroff).

However, there is probably no way to query whether the VM has already completed its boot or shutdown process, which is why a "Pause XY seconds" command would probably be the safest.

Kind regards
testit
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Backup Tool for VB VMs

Post by scottgus1 »

VBoxManage controlvm <VM name> acpipowerbutton "pushes" the "power button" on the "case" of the
VM. If the OS inside the VM is set to respond to a case button push with shutting down peacefully, then the VM will shut down. Test the command manually to be sure the VM OS is set correctly.

VBoxManage controlvm <VM name> poweroff kills the "power" to the VM just like unplugging a running PC. Most modern OS's don't like that.
testit wrote: 8. Feb 2024, 21:56 issuing a shell command immediately before the backup that shuts down the VM
vboxmanage showvminfo <vm name> tells the state of the VM.

After "VBoxManage controlvm <VM name> acpipowerbutton", go into a time-delayed loop running "vboxmanage showvminfo <vm name>", then run or pipe "find" or "grep" or whatever for you host OS on the "showvminfo" output, looking for the text:

Code: Select all

State:                       powered off
with all the spaces shown. When the text is found, the VM will be shut down.

After the backup (and file-compare for integrity check if wanted) run this to restart the VM:

vboxmanage startvm <vm name>
testit
Posts: 28
Joined: 31. Jul 2011, 14:26
Primary OS: FreeBSD
VBox Version: OSE other
Guest OSses: bisher: keine

Re: Backup Tool for VB VMs

Post by testit »

Hi,

Thank you very much, your comments above confirm my plan. I'm very curious to see if it all works in practice straight away, which would be very reassuring. :-)

Kind regards
testit
Post Reply