apiVersion: batch/v1
kind: CronJob
metadata:
  name: database-backup
spec:
  schedule: "15 23 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: database-backup
              image: mysql:8.0
              imagePullPolicy: IfNotPresent
              command:
                - /bin/sh
              args:
                - /backup_scripts/backup.sh
              volumeMounts:
                - mountPath: /backups
                  name: mysql-backup-volume
                - mountPath: /backup_scripts
                  name: mysql-backup-scripts
          restartPolicy: OnFailure
          volumes:
            - name: mysql-backup-volume
              hostPath:
                path: "/opt/mediawiki/backups"
                type: DirectoryOrCreate
            - name: mysql-backup-scripts
              hostPath:
                path: "/opt/mediawiki/backup_scripts"
                type: Directory
