I have several virtual machines running on Virtualbox. I want to take a backup of these virtual machines and store in source control for disaster recover. From what I understand, snapshots of these virtual machines aren't going to do the trick as far as disaster recovery is concerned.
These backups will be taken periodically, and I'm going to automate them using Jenkins automation server. I have been using an article from TechRepublic as a resource for operating VirtualBox from command line as far as exporting virtual appliances.
My thoughts on the process executed by the Jenkins job are as follows (all actions performed from command line):
- Power down the particular virtual machine to be backed up (and leave virtualbox running).
Run the VirtualBox export command:
vboxmanage export UBUNTUSERVER164 -o ubuntu_server_new.ova
Run command to bring the virtual machine back up.
- CD into the directory where VirtualBox virtual appliances are stored.
- Copy the newly created virtual appliance (.ova format), to a local backup directory.
- Compress (tar), the copied .ova file in the local backup directory.
- Remove the uncompressed copy of the .ova file in the local backup directory.
- Git commit the compressed virtual appliance, and Git push to BitBucket.
Some questions I have about using this approach:
- Where are VirtualBox's virtual appliances stored by default?
- What would the shell command look like to power down the virtual machine pre backup?
- What would the shell command look like to power on the virtual machine post backup?
ssh -t user@virtualmachine sudo poweroff
(and shorter :P ) – Rinzwind Jul 13 '17 at 18:47poweroff
in the guest (gracefully) closes all applications, unmounts drives and then immediately shuts down the machine much likeshutdown -h now
. See https://askubuntu.com/questions/64995/what-is-the-difference-between-shutdown-and-poweroff-commands - but you should not poweroff from VBoxManage. – Takkat Jul 14 '17 at 12:52