Revert OpenNebula volume from a snapshot
1. Common restore scenarios
1.1. Saving snapshots in the primary cluster
Use the following steps:
1.2. Saving snapshots in the backup cluster
Use the following steps:
1.3. Reverting a VM
Use the following steps:
Use the 2.4. Monitor transfer progress step afterward to follow the progress.
2. Revert procedure steps
Use the steps below to completed the scenarios listed above.
Consider that all commands can be run from any machine with StorPool, as well as the ONE control node (frontend), as it has access to the StorPool API management.
2.2. Find all remote exported snapshots for a specific volume in the primary cluster
# storpool -j snapshot list remote | jq -r '.data.snapshots[]|select(.name|endswith("<volume_name>"))|[.location,.remoteId,(.creationTimestamp|strftime("%c")),.name]|@csv'
Example output:
"Customer-Backup-01","xc7.b.84awn","Sat Jul 2 03:18:00 2022","spvc___1656731834___xc7___one-img-1-123-0"
"Customer-Backup-01","xc7.b.8428j","Sat Jul 2 04:17:41 2022","spvc___1656735434___xc7___one-img-1-123-0"
"Customer-Backup-01","xc7.b.8424i","Sat Jul 2 05:17:23 2022","spvc___1656739034___xc7___one-img-1-123-0"
"Customer-Backup-01","xc7.b.844p7","Sat Jul 2 06:18:02 2022","spvc___1656742634___xc7___one-img-1-123-0"
2.3. Transfer a remote snapshot locally
# snapshot <snapshot_name> template <template_name> remote <remote_cluster_location_name> <snapshot_global_id>
Example:
# snapshot spvc___1656731834___xc7___one-img-1-123-0 template one-ds-1 remote Client-Backup-01 xc7.b.84awn
Choosing spvc___1656731834___xc7___one-img-1-123-0
(for illustration purposes; the name can be given by the user) we are selecting the template one-ds-1
which corresponds with the number of the datastore. We also select the remote cluster location (you can list existing locations with storpool location list
) and the global ID of the snapshot (by which the snapshot is selected).
2.4. Monitor transfer progress
Monitoring can be done with /usr/lib/storpool/transfer_progress
. Alternatively, you can run the following on the primary (receiving) cluster:
# storpool -j volume quickStatus | jq -r '.data[]|select(.recoveringFromRemote==true)|[.name,.upSoonChainsCount,(.size/33554432)]|@csv'
Example output (columns: name, remaining objects, total objects):
"spvc___1656731834___xc7___one-img-1-123-0",160,32000
"spvc___1656743536___xc7___one-img-11-169-1",215,6400
"spvc___1656743592___xc7___one-img-43-509-0",25,12800
Attention
You don’t need the transfer to finish to start using the snapshot.
2.5. Undeploy the VM
Attention
Make sure that the volume of the VM is not in use! You can check if the volume is attached anywhere in the cluster via storpool attach list
on any node.
Run the following on the ONE frontend node:
# onevm undeploy --hard <ID>
Make sure the VM’s status is UNDEPLOYED:
# onevm show <ID>
# tail -f /var/log/one/ID.log
2.6. Preserve the old volume as a snapshot (optional)
To preserve the volume as a snapshot with a name of your choosing:
# storpool volume <volume_name> snapshot <snapshot_name>
2.7. Revert the volume based on the snapshot
Note
The name of the snapshot is the same as the one used in step 3.
# storpool volume <volume_name> revertToSnapshot <snapshot_name>
2.8. Create a snapshot copy in the backup cluster for preservation purposes
Create a volume from the desired snapshot and then create a new snapshot from it. Then you can export the newly created snapshot back to the primary cluster:
# storpool volume <volume_name> parent <backup_snapshot_name>
# storpool volume <volume_name> snapshot <preserved_snapshot_name>
# storpool volume <volume_name> delete <volume_name>
# storpool snapshot <preserved_volume_name> export <remote_cluster_location>