Sooner or later, everyone who has a server running will reach the point where the VM (or parts of it) irreversibly ” breaks” – by whatever means.
Those who have dedicated themselves to backing up their data in advance are now clearly at an advantage and can expect significantly lower adrenaline levels – especially if the last backup was less than 24 hours ago. Our OpenStack platform offers functionality for the automatic or manual creation of snapshots for the backup of your virtual machine(s).
> Setup automatic snapshots
Select the Snapshots tab and set a check mark for the VM to be automatically backed up and the setting is applied.
Et voilà! From now on, the OpenStack app will take care of creating a snapshot of this virtual machine every night after 00:00. As mentioned in the image, it takes seven snapshots; the eighth time it takes a snapshot, it deletes the oldest, i.e. the first, and so on.
Ergo, “7” is the default rotation value. If you want to change this, i.e. keep less than a week of daily snapshots, for example only three, you can do so as follows: Back to the “LiveView” tab > Compute > Instances > Drop-down menu (to the far right of the instance to be modified) > “Update metadata”.
Here you can now see that under “Existing Metadata” “nws_backup” exists and is set to “true”.
Write under “Available Metadata” next to the field “Custom” “rotation” , add it with the plus sign strong > Add to the “Existing Metadata”, enter the value “3” and click on “Save”.
¡¡¡In the case of databases on the VM to be backed up !!!
Since snapshots are taken while the system is running, the consistency of the databases in them is not guaranteed. I recommend setting up a cron job that creates a dump of the running DBs or other non-persistent data. It would be good if this is finished before 24:00 and can thus be seamlessly backed up.
> Create manual snapshots
If, on the other hand, you only want to back up a certain state – for example, after carrying out all the installation steps of your software landscape – you can do this manually: Compute > Instances > Create shadow copy (next to the VM to be backed up). A meaningful shadow copy name must then be assigned and create snapshot clicked.
A green success message will pop up in the top right-hand corner.
Here, as described above, attention should also be paid to databases.
> Import snapshot
If there is an accident or any other case of necessary resetting, the backup is imported as if a new VM were started.
Compute > Instances > Start instance.
Details > Set instance name
Source > Select boot source:
Here there are two possibilities where your snapshot is located:
- either > “data carrier snapshot” (in the case of VMs “with data carrier” or “with volume”: system data carrier in our Ceph storage, in total triple replication at two locations)
- or > “Image” or “Instance Snapshot” (in the case of VMs “without data carrier” or “without volume”: system data carrier only on the hypervisor)
Variant, networks, security groups and key pair are to be set as usual.
As a result, you will now have two similar VMs:
To complete the new target state, it remains to detach the floating IP from the instance to be discarded (drop-down menu to the far right of the instance) and assign it to the new one. If it is certain that the old one is no longer needed, it can then also be deleted so as not to continue to cause unnecessary costs.
This procedure is not only suitable for disaster recovery. It can also be used to set up an identical VM or to test larger patches away from the productive areas.
> Mount snapshot as data carrier
If you only want to access the data contained in the snapshot, it is also possible to create a data carrier from the snapshot and attach it to another running VM.
This is possible in two steps:
Compute > Images > Drop-down menu (to the far right of the image to be used) > Create data carrier > Create data carrier..
Continue via Disk > Disk > Drop-down menu (far right of the disk to be used) > Manage attachments.
The instance to which the drive is to be connected must be selected and confirmed.
Now the disk is available, on Ubuntu for example as /dev/sdb1 .