Create Backup and Push CronJob

This is required for periodic automatic backups to work.

Create a file named backup-and-push-cronjob.yaml with following content.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: backup-and-push
spec:
  schedule: "0 0 * * *"
  jobTemplate:
    spec:
      backoffLimit: 1
      template:
        spec:
          securityContext:
            supplementalGroups: [1000]
          initContainers:
          - name: backup
            image: frappe/erpnext-worker:${VERSION}
            args: ["backup"]
            imagePullPolicy: IfNotPresent
            env:
              - name: "WITH_FILES"
                value: "1"
            volumeMounts:
              - name: sites-dir
                mountPath: /home/frappe/frappe-bench/sites
          containers:
          - name: push-backup
            image: frappe/erpnext-worker:${VERSION}
            args: ["push-backup"]
            imagePullPolicy: IfNotPresent
            volumeMounts:
              - name: sites-dir
                mountPath: /home/frappe/frappe-bench/sites
            env:
              - name: "BUCKET_NAME"
                value: ${BUCKET_NAME}
              - name: "REGION"
                value: ${REGION}
              - name: "ACCESS_KEY_ID"
                valueFrom:
                  secretKeyRef:
                    key: accessKey
                    name: push-backup-s3-secret
              - name: "SECRET_ACCESS_KEY"
                valueFrom:
                  secretKeyRef:
                    key: secretKey
                    name: push-backup-s3-secret
              - name: "ENDPOINT_URL"
                value: "${ENDPOINT_URL}"
              - name: "BUCKET_DIR"
                value: "${BUCKET_DIR}"
          restartPolicy: Never
          volumes:
            - name: sites-dir
              persistentVolumeClaim:
                claimName: ${SITES_PVC}
                readOnly: false

Change the following properties:

Create the resource using:

$ kubectl create -n <namespace> -f backup-and-push-cronjob.yaml