Snapshots¶
This page explains how to use Snapshots with GandiCloud VPS.
You can find complete information and pricing about the options and features on our GandiCloud VPS page.
Snapshosts in GandiCloud¶
A snapshot is an instant picture of your volume at a given point in time. It allows you to restore your data to a previous version, or, for example, keep a specific version of your volume in order to duplicate a configuration.
While a snapshot is very useful for rollbacks, it is stored in the same location as the volume itself, and therefore should not be considered a real backup (which would need to be stored elsewhere).
In GandiCloud you have two snapshot features:
Manual snapshots: You can manually create a snapshot from a volume. This snapshot is permanent; it will only be deleted if you choose to manually delete it.
Automatic snapshots: You can decide to activate automatic snapshots on a volume. Then, a snapshot is created each day. We store these snapshots for a limited time, as listed below.
1 snapshot is at least 1 month old,
1 snapshot is at least 1 week old,
1 snapshot is at least 24 hours old,
We keep a maximum of 11 snapshots.
Manage Your Snapshot in the Gandi Interface¶
All the snapshot options are available from the overview page of a volume.
Manage the snapshots with the Command Line Interface (CLI)¶
The CLI is a good option for the user who wants to script or automate some tasks. We offer the standard OpenStack CLI.
First, ensure that you have already configured your access to the CLI.
Then you can use the following commands to manage the snapshots of your GandiCloud volumes.
Create a snapshot¶
If you want to create a manual snapshot from an existing, active volume use the following command.
openstack volume snapshot create --force --volume <volume_id> <snapshot_name>
Be sure to include the following:
–force: When included, a snapshot will be created even if the volume is in use.
<volume_id>: The name or the id of the volume
<snapshot_name>: The name you want to give to the snapshot
Delete a Snapshot¶
The following command will delete a snapshot:
openstack volume snapshot delete <snapshot_name>
List Your Snapshots¶
This command displays all the snapshots that belong to you:
openstack volume snapshot list
Use this command to access to all the information related to a specific snapshot:
openstack volume snapshot show <snapshot_id>
Use this command to display the list of the snapshots associated with a volume:
openstack volume snapshot list --volume <volume_id>
Create a Volume from a Snapshot¶
This command creates a new volume from an existing snapshot:
openstack volume create --snapshot <snapshot_id> --size <size_in_GB> <volume_name>
Be sure to include the following:
<snapshot_id>: The snapshot to use for the restore
` –size <size_in_GB>`: Specify a size for the new volume. This parameter is optional, since by default the size will be the same size as the snapshot. However, if you want to create a bigger new volume you can specify it here.
<volume_name> : The name of the new volume
Restore a Volume to a Previous Version¶
To restore a previous version of your volume, you will need to create a temporary volume from the wanted snapshot, then boot your server into rescue mode and overwrite your disk with the content of the temporary disk.
First, add a label to the partition you want to revert to a previous state, so you can easily find it later.
lsblk -o NAME,PATH,UUID,LABEL,TYPE,MOUNTPOINT,SIZE,FSSIZE,FSUSED,FSUSE%
# locate the device name of the partition to restore, e.g. `/dev/xvda1`
sudo e2label <device_name> "REVERT_ME"
Be sure to include the following:
<device_name>: The partition to revert (e.g.
/dev/xvda1
)
At some point later in the process, you will have 2 disks with the same UUID and only one partition with this label.
If you cannot access your server (e.g. it is not starting), you can do this operation using the rescue mode.
Once this is done, create a new volume from the snapshot you want to restore. This volume containing your snapshot data will be called the temporary volume for the rest of this process.
When your temporary volume is in status available
, attach it to your server:
openstack server add volume <server_id> <temporary_volume_id>
And reboot your server into rescue mode:
openstack server rescue --image "Rescue (Debian)" <server_id>
Access your server using ssh or the emergency console and locate the partition you want to overwrite:
$ lsblk -o NAME,PATH,UUID,LABEL,TYPE,MOUNTPOINT,SIZE,FSSIZE,FSUSED,FSUSE%
NAME PATH UUID LABEL TYPE MOUNTPOINT SIZE FSSIZE FSUSED FSUSE%
xvda /dev/xvda disk 2G
|-xvda1 /dev/xvda1 97bb8638-cb1a-4917-9d75-222c701a2cc7 RESCUEROOT part / 1.9G
|-xvda14 /dev/xvda14 part 3M
`-xvda15 /dev/xvda15 7FFD-8BD9 part /boot/efi 124M
xvdb /dev/xvdb disk 25G
`-xvdb1 /dev/xvdb1 9a03b9ab-ac87-455e-bd8d-83318a953647 part 25G 24.8G 2.2G 9%
xvdc /dev/xvdc disk 25G
`-xvdc1 /dev/xvdc1 9a03b9ab-ac87-455e-bd8d-83318a953647 REVERT_ME part 25G
The partition having the label “REVERT_ME” is your current one and the partition with the same UUID/PARTUUID is the one from your temporary volume (/dev/xvdb1
in the above example).
If you want to make sure you are looking at the right partitions, you can also mount them and inspect their content:
mkdir disk1 disk2
sudo mount /dev/xvdb1 disk1
sudo mount /dev/xvdc1 disk2
ls disk1
ls disk2
# Do not forget to unmount
sudo umount /dev/xvdb1
sudo umount /dev/xvdc1
Now, overwrite the content of the partition to be restored using the partition from your temporary volume:
sudo dd if=<partition_to_read_from> of=/dev/disk/by-label/REVERT_ME bs=100M
Be sure to include the following:
<partition_to_read_from>: The partition containing your snapshot data (
/dev/xvdb1
in the above example)
This operation can take some time, around 5 minutes for a disk of 25GB.
Note that the operation will also remove the label added previously and restore any label set at the time of the snapshot.
Once the copy is done, you can deactivate the rescue mode and detach the second volume:
openstack server unrescue <server_id>
openstack server remove volume <server_id> <temporary_volume_id>
Verify that your volume is now in the correct state and contains the data you want, then finally delete the temporary volume:
openstack volume delete <temporary_volume_id>