apiVersion: batch/v1beta1
kind: CronJob
metadata:
  labels:
    app.kubernetes.io/name: backup
  name: backup
  namespace: unifi
spec:
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - command:
            - rsync
            - -av
            - --delete
            - -e
            - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
            - root@192.168.2.7:/data/autobackup/
            - /backup/
            image: quay.io/paulfantom/rsync
            name: copier
            resources:
              limits:
                cpu: 800m
                memory: 100Mi
              requests:
                cpu: 520m
                memory: 20Mi
            volumeMounts:
            - mountPath: /backups
              name: backups
            - mountPath: /root/.ssh
              name: ssh
              readOnly: true
          restartPolicy: OnFailure
          volumes:
          - name: backups
            persistentVolumeClaim:
              claimName: backup
          - name: ssh
            secret:
              defaultMode: 384
              secretName: sshprivkey
  schedule: 6 6 * * sun
  successfulJobsHistoryLimit: 1
