Normally I would suggest people to start running a virtual machine that needs backing up on something else other than VirtualBox however because of my recent migration from VMWare to VirtualBox this question arose. I am a Windows Insider and I use a VM to test the image and new features. During this process I most of the time break something and need to get back to where I started before. Nothing a simple snapshot doesn’t fix but actually making automated backups are a different story.
So I decided to write something that could do that. I should stop the VM and wait for it to be shutdown, Export the appliance to a location and if I want compress the thing down if possible. After the export it starts the VM back up. This way I can have a neatly packed organized backup structure of my VM that I Import at any time and will.
For the compression part it requires that you have 7-Zip installed. I used 7-Zip instead of the Compress-Archive command because of a file limiting bug with the command as of writing this.
Don’t get me wrong this is not an optimal way of doing things probably but for my use case it works great. If I update the script at any point I will write back here.
UPDATE 2019-07-30: Added a check if the destination folder exists and if not create it. Also changed up a Write-Verbose typo.
UPDATE 2019-12-23: Created a GitHub repo to manage script code and additions. https://github.com/perplexityjeff/Backup-VirtualBox-PowerShell
Good day!
Do you have plans to have any kind of shared repo on github/gitlab? I.e. i wanna extend it to upload backup results to s3 with limit on doing it via metered connection. Also, some params are hardcoded – i.e. archive type, while someone may want to use 7zip format instead of zip and so on
I have no plans currently to extend the functionality but thank you for the feedback.
I might GitHub repo it so people can add to it!
Edit: I made a repo for it: https://github.com/perplexityjeff/Backup-VirtualBox-PowerShell
Jeff