apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: redis-backup-cron
spec:
  schedule: "00 1 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            parent: "redis-backup-cron"
        spec:
          containers:
          - name: backup
            image: 'docker.io/bitnami/redis:6.0.10-debian-10-r1'
            command: ["/bin/bash"]
            args: ["-c", "cp /data/dump.rdb /data/dump.rdb.$(date +%F); find /data -name '*.rdb.*' -type f -mtime +30 -exec rm -f {} ';'"]
            volumeMounts:
              - mountPath: /data
                name: redis-backup-data
          imagePullSecrets:
            - name: docker-pull-secret
          restartPolicy: OnFailure
          volumes:
            - name: redis-backup-data
              persistentVolumeClaim:
                claimName: redis-data-hubot-redis-master-0
