How to backup a vm incrementally

This is for discussing general topics about how to use VirtualBox.
Post Reply
cyvbox
Posts: 7
Joined: 26. Dec 2010, 13:43
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: linux

How to backup a vm incrementally

Post by cyvbox »

As far as I know, there are a few methods we can use to backup a vm:
1. copy the vdi file manually
2. clonehd the vdi
3. use "export applicance"
The vdi file of my vm is 40GB. It takes a lot time to do a full backup.
I'm wondering, is there a way to backup a vm incrementally, i.e. only backup
the differences I made to a vm since the last backup?

any ideas?
uli100
Posts: 59
Joined: 29. Oct 2009, 18:34
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Various Linux Distros
Location: Stuttgart, Germany

Re: How to backup a vm incrementally

Post by uli100 »

What about this:

* For the first backup, create a snapshot and copy the baseline vdi file (probably roughly 40GB)
* Since you created a snapshot, the basline vdi file will not be modified any more, so it is constant
* For the next backup, create another snapshot and copy the differencing vdi file (size depends on the number of changes you made in the meantime)
* Since you created two snapshots, the baseline vdi file and the differencing vdi file will not be modified any more, so they are constant
* and so on...

You end up with lots of snapshots. You may delete/merge old snapshots.

Note: I didn't try to do backups like this. It is just an idea. Not sure if it will work.

Best regards, Uli
cyvbox
Posts: 7
Joined: 26. Dec 2010, 13:43
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: linux

Re: How to backup a vm incrementally

Post by cyvbox »

Good idea. But how can I use the baseline vdi and the snapshots vdi to reconstruct a working vm?
uli100 wrote:What about this:

* For the first backup, create a snapshot and copy the baseline vdi file (probably roughly 40GB)
* Since you created a snapshot, the basline vdi file will not be modified any more, so it is constant
* For the next backup, create another snapshot and copy the differencing vdi file (size depends on the number of changes you made in the meantime)
* Since you created two snapshots, the baseline vdi file and the differencing vdi file will not be modified any more, so they are constant
* and so on...

You end up with lots of snapshots. You may delete/merge old snapshots.

Note: I didn't try to do backups like this. It is just an idea. Not sure if it will work.

Best regards, Uli
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: How to backup a vm incrementally

Post by vbox4me2 »

Make the vdi immutable and backup the single snapshot, this does rely on some vbox versions which have a bug where this snapshot is not deleted :mrgreen: but again this snapshot can grow beyond the main vdi.

Consider using rsync with the inplace sync option.
hustille
Posts: 12
Joined: 5. May 2008, 18:00

Re: How to backup a vm incrementally

Post by hustille »

I use bacula for backup with full backups every month, differential every week and daily incremental. Before the job a shell script is run that manages VM snapshots:
A full backup deletes all snapshots, so that a single base vdi is stored. For differential only daily snapshots are deleted, which consolidates the changes into a single weekly difference. Every day and week new snapshots are taken and labeled as such.

To get back an old version I restore the preceding full and differential backups and some incrementals. That gives me the base vdi and snapshots and the machine description belonging to the target state. Only the execution state gets lost if a machine was running during the backup. Or the script might shut down or save the machines. Anyway, after moving the restored files into place the machines should just work.

MfG, Ulrich
cyvbox
Posts: 7
Joined: 26. Dec 2010, 13:43
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: linux

Re: How to backup a vm incrementally

Post by cyvbox »

Which files do I need to backup besides the snapshot files in order to reconstruct a vm with snapshots?
hustille wrote:I use bacula for backup with full backups every month, differential every week and daily incremental. Before the job a shell script is run that manages VM snapshots:
A full backup deletes all snapshots, so that a single base vdi is stored. For differential only daily snapshots are deleted, which consolidates the changes into a single weekly difference. Every day and week new snapshots are taken and labeled as such.

To get back an old version I restore the preceding full and differential backups and some incrementals. That gives me the base vdi and snapshots and the machine description belonging to the target state. Only the execution state gets lost if a machine was running during the backup. Or the script might shut down or save the machines. Anyway, after moving the restored files into place the machines should just work.

MfG, Ulrich
hustille
Posts: 12
Joined: 5. May 2008, 18:00

Re: How to backup a vm incrementally

Post by hustille »

AFAIK:
VirtualBox.xml, which contains a registry of all the parts
Machines/*/*.xml, which describe the machines
.vdi files for the base image and all snapshots
.sav files for snapshots of running (or saved) states
*.img for floppies, if any

I prefer to backup the whole VB directory; saves thinking and the bulk is in the VDIs anyway.

MfG, Ulrich
Post Reply