1

How do I configure Longhorn backup so it executes some bash scripts in the pod before and after snapshot/backup is taken?

Something similar to Velero's backup hooks.

  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
Anton
  • 3,587
  • 2
  • 12
  • 27

1 Answers1

1

Apparently not possible at the moment, according to the longhorn github issue.

You can orchestrate similar behaviour by using volume snapshot

kubectl exec mypod-id -- app_freeze
kubectl apply -f volumesnapshot.yaml
kubectl exec mypod-id -- app_thaw

Where volumesnapshot.yaml is:

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: my-longhorn-snapshot
spec:
  volumeSnapshotClassName: longhorn
  source:
    persistentVolumeClaimName: my-longhorn-pvc

See example for IRIS database: https://community.intersystems.com/post/amazon-eks-and-iris-high-availability-and-backup

Anton
  • 3,587
  • 2
  • 12
  • 27