---
#
# Cronjob to back up my longhorn backups to the cloud
#
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  namespace: default
  name: rclone-sync-longhorn
  annotations:
    fluxcd.io/ignored: "false"
    fluxcd.io/automated: "false"
spec:
  # Run once a day, every day, starting at 6PM
  schedule: "0 18 * * *"
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 1
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
          - name: rclone
            image: rclone/rclone:1.53.0
            imagePullPolicy: IfNotPresent
            env:
            - name: TZ
              value: "America/New_York"
            command:
            - "rclone"
            - "-v"
            - "--config"
            - "/data/rclone.conf"
            - "sync"
            - "--ignore-errors"
            - "--fast-list"
            - "--b2-hard-delete"
            - "--transfers"
            - "24"
            - "--checkers"
            - "24"
            - "--bwlimit"
            - "25M"
            - "minio:longhorn"
            - "b2-longhorn-crypt:/"
            volumeMounts:
            - mountPath: /data
              name: rclone
              subPath: rclone
              readOnly: false
          volumes:
          # Location of rclone.conf
          - name: rclone
            persistentVolumeClaim:
              claimName: nfs-data-rocinante-pvc
