























Snapshot rollback reverts an RBD image to its state at a specific snapshot point. All changes made after the snapshot was created are permanently discarded. This is useful for:
Important: Rollback is destructive. Data written after the snapshot will be lost. Always verify you have a newer backup if needed.
rbd snap ls mypool/myimageOutput:
SNAPID NAME SIZE PROTECTED TIMESTAMP
1 snap-before-upgrade 10 GiB no Tue Mar 31 09:00:00 2026
2 snap-after-deploy 10 GiB no Tue Mar 31 11:00:00 2026For Kubernetes PVCs, scale down the workload:
kubectl scale deployment myapp --replicas=0 -n myappWait for pods to terminate:
kubectl wait --for=delete pod -l app=myapp -n myapp --timeout=120sThen confirm Ceph sees no open clients for the image:
rbd status mypool/myimagerbd snap rollback mypool/myimage@snap-before-upgradeThis rewrites the image to match the snapshot state. The time taken depends on how much data changed after the snapshot.
Progress output:
Rolling back to snapshot: 100% complete...done.Map the image and check the filesystem:
DEV=$(rbd device map mypool/myimage)
mkdir -p /mnt/check
mount "$DEV" /mnt/check
ls /mnt/check
umount /mnt/check
rbd device unmap "$DEV"kubectl scale deployment myapp --replicas=3 -n myappThe Kubernetes VolumeSnapshot API does not support in-place rollback. To "roll back" a PVC in Kubernetes, you restore from snapshot by creating a new PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myapp-pvc-rolled-back
spec:
storageClassName: rook-ceph-block
dataSource:
name: snap-before-upgrade
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10GiThen update your deployment to use the new PVC name.
Before rolling back, protect the current state as a new snapshot:
rbd snap create mypool/myimage@pre-rollback-$(date +%Y%m%d%H%M%S)This ensures you can undo the rollback if needed.
RBD snapshot rollback reverts a block device image to a previous state using rbd snap rollback. Always stop all users of the image and confirm it has no open clients before rolling back, and create a pre-rollback snapshot to preserve the ability to undo the operation. For Kubernetes PVC rollback, create a new PVC from the target VolumeSnapshot and update the workload's volume reference rather than attempting in-place rollback.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。