apiVersion: batch/v1
kind: CronJob
metadata:
  name: backup
spec:
  schedule: "0 20 */14 * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 5
  failedJobsHistoryLimit: 3
  jobTemplate:
    metadata:
      labels:
        t00n.de/restic-backup: "true"
    spec:
      backoffLimit: 3
      activeDeadlineSeconds: 300
      template:
        spec:
          nodeSelector:
            kubernetes.io/hostname: k3sh0
          restartPolicy: OnFailure
          containers:
            - name: backup-photoprism
              image: gitea.t000-n.de/t.behrendt/backupsidecar:6ff6e8759e827b9aa8ec7ecec4356cc04e4ca75a@sha256:f0841b9d74c6c9db8445d130b79c631a5526a2890ce34371859b3bb65f0ee5be
              env:
                - name: BACKUP_MODE
                  value: "directory"
                - name: RESTIC_REPOSITORY
                  value: "rest:http://restserver.restic.svc.cluster.local:8000/photoprism"
                - name: RESTIC_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: backup-secret
                      key: restic_password
                - name: RESTIC_REST_USERNAME
                  valueFrom:
                    secretKeyRef:
                      name: backup-secret
                      key: restic_rest_username
                - name: RESTIC_REST_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: backup-secret
                      key: restic_rest_password
                - name: GOTIFYHOST
                  value: "https://gotify.t000-n.de"
                - name: GOTIFYTOKEN
                  valueFrom:
                    secretKeyRef:
                      name: backup-secret
                      key: gotify_token
                - name: GOTIFYTOPIC
                  value: "Photoprism Backup"
                - name: SOURCEDIR
                  value: "/data"
              volumeMounts:
                - name: source-data
                  mountPath: /data
          volumes:
            - name: source-data
              hostPath:
                path: /mnt/longhorn1/svc/photoprism/main
                type: Directory
