(01)Deploy to cluster
Linux
1kubectl apply -f .2kubectl get all3kubectl get pods -wScheduled backup job — runs on a cron schedule inside the cluster
cronjob-backup.yml
1apiVersion: batch/v12kind: CronJob3metadata:4 name: db-backup5spec:6 schedule: "0 2 * * *"7 jobTemplate:8 spec:9 template:10 spec:11 restartPolicy: OnFailure12 containers:13 - name: backup14 image: postgres:16-alpine15 command:16 - /bin/sh17 - -c18 - pg_dump -h postgres -U app appdb > /backup/dump.sql19 volumeMounts:20 - name: backup21 mountPath: /backup22 volumes:23 - name: backup24 emptyDir: {}Step 01
1kubectl apply -f .2kubectl get all3kubectl get pods -w1kubectl delete -f .