Closed Skaronator closed 2 years ago
Hi,
Indeed, Kubernetes is already supported. You only have to change the command.
A CronJob like this may work (WARNING: I haven't tested it):
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup
spec:
schedule: "0 3 * * sun"
jobTemplate:
spec:
template:
spec:
volumes:
- name: db_data
host:
secretName: mysecret
containers:
- name: backup
image: fradelg/mysql-cron-backup:<my-tag>
imagePullPolicy: IfNotPresent
command:
- /backup.sh
volumes:
- name: db_data
hostPath:
path: /data/backup
env:
- name: MYSQL_HOST
value: my_mariadb
- name: MYSQL_USER
value: root
- name: MAX_BACKUPS
value: 15
- name: CRON_TIME
value: 0 3 * * *
- name: GZIP_LEVEL
value: 9
- name: $MYSQL_PASS
valueFrom:
secretKeyRef:
name: mysql
key: password
restartPolicy: OnFailure
volumeMounts:
- name: db_data
mountPath: "/backup"
readOnly: true
Hi @fradelg,
Totally forgot that I can just overwrite the command itself. And the good thing is that the bachup.sh script contains the cleanup logic as well.
Just gave this a try and it seems to work just fine :)
Thanks
Hi,
Would it be possible to add a
RUN_ONCE
option to the image which means that it'll do a backup on startup (likeINIT_BACKUP
) but after that will exit/stop the container?I'd like to continue using the image but with a Kubernetes Cronjob. So, the Container orchestrator takes care of scheduling the container.