Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to setup a server running in a VirtualBox virtual machine on a Linux host system.

What would be an effective way to backup this virtual server "whole", so that in the event of either a host or guest system failure, I can just restore the backed up virtual server?

Please also let me know how I would restore the backup. Thank you!

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

Paraphrased from John's answer, "Treat the virtual as you would a physical machine". Any software/method to backup while running will work. You may also want a backup of the virtual machine's configuration file (.vbox) if the backup method doesn't already include it. Most bare-metal backups are done without the standard system running. Most incremental/differential data backups can be performed with the system running.

Be aware that the "VBoxManage clonehd" (clonevdi is deprecated) will change the UUID. Many current Linux distributions use UUID's for mounting and you will need to modify the UUID or /etc/fstab to get the cloned disk to boot.

Also clonehd does not copy the machine, only the disk. You may have specific virtual system settings necessary for correct running of the virtual, multiple NICs, large memory setting, etc..

Try to use multiple disks to separate system from data to reduce the down time for clone or backup. If the virtual is a web server, use a separate disk for www-root where most daily changes will be made. No need to repeatedly backup the system disk unless programs or config files are updated. Don't forget to backup the logs if you need them.

Also look into using VirtuaBox immutable disks after initial virtual install and setup. The immutable system disk can be shared among many virtual machines. It is read-only and only needs to be backed up once, or whatever retention number you feel safe with, usually three or four copies is sufficient. Only the differencing disks will need to be backed up regularly.

Most of our virtual servers are pre-backed up by virtue of source revision control. All changes to the virtual machine configuration files (.vbox), the virtual's etc config files and virtual data are published through source control which is backed up externally. A rebuild/restore consists of checking out the vbox machine file, booting up the virtual machine against the immutable and reloading the difference disk from source control to a checkpoint or branch tag. This works well for services servers.

Virtual client test machines (different versions of windows) usually are too cumbersome for this method and need export/import, clonehd or clonezilla type backups.

Clonezilla bare-metal backup/restore - boot virtual to clonezilla iso and an extra attached backup data disk or use shared folders for the backup destination. This backs up and compresses in one pass. Clonehd and export will need space for up to three copies temporarily during the backup if you also compress after the clonehd operation. After backup or restore remove clonezilla iso mount, extra backup disk or share folders and restart system. Restore is the same procedure as backup.

If you use any method other that export/import you may need to fiddle the UUIDs in the virtual machine config (.vbox) file or within the virtuals /etc/fstab (sometimes even with export/import for /etc/fstab) to get things working after a restore/rebuild.

Export and import is the brain-dead method. Export will copy both machine settings and disk. It will take a long time and use nearly double the virtual's disk space. The virtual should not be running during export or import.

If you want the absolute minimal downtime for your virtuals and minimal data transfer for incremental backups, look at using openIndiana (Solaris) or variants running ZFS as a virtual host system. Easy snapshot, replication and de-duplication. Clean snapshots of virtuals take less time than the shutdown/restart sequence on the virtual. The shutdown ensures database integrity, if running SQL databases and enforces lock-out/no changes are made during backup. After the shutdown/snapshot/restart sequence is completed, usually less than a few minutes, the virtual is running/usable. Then use ZFS sync to transfer only the snapshot changes to another backup machine or external disk at your leisure.

share|improve this answer
    
Thanks for such a detailed answer! –  hpy May 30 '11 at 15:35
add comment

Copy .vdi file in the HardDisks directory to the safe place. (you can use VBoxManage clonevdi ...).

share|improve this answer
1  
can I do this while the virtual server is running? Or do I have to briefly shutdown the server whenever I do a backup? Also, how would I restore the backup? Thanks. –  hpy May 29 '11 at 17:28
    
Each virtual machine per .vdi will need to be briefly shutdown. –  user48838 May 30 '11 at 2:13
    
I thumbed down because I have determined that this is not a viable option as VirtualBox gets upgraded. For example I used this approach initially way back on version 2.x. Today with 4.1.x I was unable to boot instances I attempted to restore due to incompatibility in the config / xml files. Manual changes don't help. We haven't tested extensively yet, but exporting the VM as an Appliance is more / better likely to carry over the hardware configuration as well. –  Joshua Jan 27 '12 at 19:08
add comment

You can either export the VM, which can them be imported into the same or another host, or you can use regular backup tools, just as you would with a physical host. There is no real reason to treat a VM any differently to a physical machine for backup purposes.

share|improve this answer
    
You mean use "regular backup tools" on the host? If so, will it work when the virtual machine is running? Thanks. –  hpy May 29 '11 at 17:29
    
@penyuan - no, I mean use regular backup tools on the guest. Treat both the host and guest as if they are two separate and physical machines and you'll have far fewer problems. –  John Gardeniers May 29 '11 at 21:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.