If you want to be able to operate with snapshots yourself, you need to tell us this request.
A snapshot is a read-only logical copy of an image at a particular point in time: a checkpoint. One of the advanced features of Ceph block devices is that you can create snapshots of images to retain point-in-time state history. Ceph also supports snapshot layering, which allows you to clone images (e.g., a VM image) quickly and easily. Ceph block device snapshots are managed using the rbd command and multiple higher level interfaces, including QEMU, libvirt, OpenStack and CloudStack.
A In case the RBD image is NOT shared across more machines (see the case B), but there is even minimal risk of mapping your RBD and mounting your filesystem on multiple machines we recommend you to use --exclusive option. In this case, you have to create RBD snapshot on the unmapped RBD image always. You should also make sure that your image is not being mapped on any other device. You can use the command #rbd –id client_name status rbd_pool_name/rbd_image_name. In case that image is not mapped on any machine you should get the following output Watchers: none.
B In case you don't use the option --exclusive it is sufficient to use fsfreeze command. After the snapshot is done you can enable I/O via fsfreeze with the option -unfreeze. More detail can be found on the man page of fsfreeze(8).
The following procedures demonstrate how to create, list, and remove snapshots using the rbd command.
Data increments resulting from the use of snapshots are included in the agreed quota.
To create a snapshot with rbd, specify the snap create option, the pool name and the image name.
rbd snap create {pool-name}/{image-name}@{snap-name}
For example:
rbd snap create rbd/foo@snapname
To list snapshots of an image, specify the pool name and the image name.
rbd snap ls {pool-name}/{image-name}
For example:
rbd snap ls rbd/foo
To rollback to a snapshot with rbd, specify the snap rollback option, the pool name, the image name and the snap name.
rbd snap rollback {pool-name}/{image-name}@{snap-name}
For example:
rbd snap rollback rbd/foo@snapname
For safe snapshots handling we strongly recommend assigning Protected to each snapshot you create. Protected attribute ensures that you can't accidentally delete the existing snapshot.
rbd snap protect {pool-name}/{image-name}@{snapshot-name}
Example:
rbd snap protect rbd/foo@snapname
Unprotect the snapshots
rbd snap unprotect {pool-name}/{image-name}@{snapshot-name}
Example:
rbd snap unprotect rbd/foo@snapname
To delete a snapshot with rbd, specify the snap rm subcommand, the pool name, the image name and the snap name.
rbd snap rm {pool-name}/{image-name}@{snap-name}
For example:
rbd snap rm rbd/foo@snapname
Snapshot is possible to map and mount in read-only mode:
rbd map {pool-name}/{image-name}@{snap-name} mount /dev/rbd/{pool-name}/{image-name}@{snap-name} /mnt/{mountpoint} -o ro
Example:
rbd map rbd/foo@snapname mount /dev/rbd/rbd-pool/foo@snapname /mnt/snap -o ro
Be aware: some filesystems require to use of additional options for mount
command - e.g. XFS:
mount /dev/rbd/rbd-pool/foo@snapname /mnt/snap -o ro,norecovery