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: redis:3.2
            command: ["/bin/bash"]
            args: ["-c", "cp /var/lib/redis/data/dump.rdb /var/lib/redis/data/dump.rdb.$(date +%F)", "find /var/lib/redis/data -name '*.rdb.*' -type f -mtime +30 -exec rm -f {} \\;"]
            volumeMounts:
              - mountPath: /var/lib/redis/data
                name: redis-backup-data
          restartPolicy: OnFailure
          volumes:
            - name: redis-backup-data
              persistentVolumeClaim:
                claimName: redis

