Taking a snapshot means duplicating the disk image as it is at a certain moment. The image is copied as it is at that particular moment when the snapshot is taken and then stored in the secondary storage. You can take an unlimited number of snapshots, however, it costs to have them stored, therefore we recommend to be reasonable and not take more than 3-4. Let's see how it is done.
Login, go to storage (i presume you have already at least one instance in any state-running, stopped, restarting, etc) and you see something like this when you hover over the + sign near any of your drive images (can be data or root):
As you see, there are clear buttons: Take snapshot and Setup recurring snapshots.
If we click the first, the snapshot is taken immediately (depending on how big your disk is, it may take a while), if we click the second we are taken to another screen where we can setup automatic back-up (snapshots):
Notice that you can setup hourly, daily, weekly and monthly snapshots. I have chosen daily, at 4 AM CET and I decided to keep the last three. That is because i wish to take them at a more quiet hour in order to avoid excessive read/write on the disk during the snapshot and create load problems on the VM, you may also put some minutes after, for example 27, so you are reasonably sure not everyone is making snapshots at that moment... Click add.
What will happen is that each day at 4 AM the system will take a snapshot of the disk image and if there are already 3 in the storage, will delete the oldest after the current one was successful.
You can continue to add more automated snapshots, but they will add up in your secondary storage, so, use this with caution:
That is it ! You have set up automated back-ups !
A few words of caution:
- If you have multiple disks, please keep in mind KVM does not allow taking snapshots of more disks in the same time. As a result, if you do not set them apart, say, 10 minutes each, they will fail and then there is a bug that does not allow for the deletion of some failed backups, we will have to delete manually until this bug is fixed. If you will encounter synchronization issues on multiple disks if they are not backed up in the same time, you can either do this with the API (shutdown vm, take snapshots 10 minutes apart, start VM) or use only one disk as big as needed installing from the ISO (the templates are of fixed size).
- The snapshot does not save the content of the memory, only the disk image, so, if you have a busy database, for example, which didn't flush everything to disk, you will lose the data stored in the memory. Most databases have mechanisms to protect from these situations, nevertheless, restoring such a snapshot will not resume the VM as it was at the time of the snapshot, it will be like it was rebooted forcefully. Be sure to consider this.