Longhorn backup/snapshot 钩子
Longhorn backup/snapshot hooks
如何配置 Longhorn 备份,以便它在 snapshot/backup 被占用之前和之后在 pod 中执行一些 bash 脚本?
类似于 Velero 的备份挂钩。
annotations:
backup.velero.io/backup-volumes: data
pre.hook.backup.velero.io/command: "['/usr/bin/mysql', '-e', '\"flush tables with read lock;\"']"
pre.hook.backup.velero.io/container: mysql
post.hook.backup.velero.io/command: "['/usr/bin/mysql', '-e', '\"unlock tables;\"']"
post.hook.backup.velero.io/container: mysql
目前显然不可能
您可以使用 volume snapshot
协调类似的行为
kubectl exec mypod-id -- app_freeze
kubectl apply -f volumesnapshot.yaml
kubectl exec mypod-id -- app_thaw
其中 volumesnapshot.yaml
是:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-longhorn-snapshot
spec:
volumeSnapshotClassName: longhorn
source:
persistentVolumeClaimName: my-longhorn-pvc
参见 IRIS 数据库示例:https://community.intersystems.com/post/amazon-eks-and-iris-high-availability-and-backup
如何配置 Longhorn 备份,以便它在 snapshot/backup 被占用之前和之后在 pod 中执行一些 bash 脚本?
类似于 Velero 的备份挂钩。
annotations:
backup.velero.io/backup-volumes: data
pre.hook.backup.velero.io/command: "['/usr/bin/mysql', '-e', '\"flush tables with read lock;\"']"
pre.hook.backup.velero.io/container: mysql
post.hook.backup.velero.io/command: "['/usr/bin/mysql', '-e', '\"unlock tables;\"']"
post.hook.backup.velero.io/container: mysql
您可以使用 volume snapshot
协调类似的行为kubectl exec mypod-id -- app_freeze
kubectl apply -f volumesnapshot.yaml
kubectl exec mypod-id -- app_thaw
其中 volumesnapshot.yaml
是:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: my-longhorn-snapshot
spec:
volumeSnapshotClassName: longhorn
source:
persistentVolumeClaimName: my-longhorn-pvc
参见 IRIS 数据库示例:https://community.intersystems.com/post/amazon-eks-and-iris-high-availability-and-backup