k8s-manifests/backups/base/backup-cronjob.yaml

61 lines
2.2 KiB
YAML
Raw Permalink Normal View History

2025-02-07 13:15:20 +01:00
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup
spec:
schedule: "0 0 * * *"
2025-02-07 15:44:49 +01:00
concurrencyPolicy: Forbid
2025-02-07 13:15:20 +01:00
jobTemplate:
spec:
2025-02-07 13:21:37 +01:00
template:
spec:
2025-02-07 15:33:39 +01:00
volumes:
- name: backup-storage
emptyDir: {}
2025-02-07 15:44:49 +01:00
- name: ipc-storage
emptyDir: {}
2025-02-07 13:21:37 +01:00
restartPolicy: Never
containers:
- name: backup-container
image: docker.sunet.se/drive/duplicity:bookworm-slim-1
2025-02-07 15:44:49 +01:00
command: ["bash"]
2025-02-07 16:03:15 +01:00
args: [ "-c", "duplicity /backup_storage rclone://destination:$(BUCKET) --no-encryption --full-if-older-than 1M; touch /backup_ipc/stop" ]
2025-02-07 13:21:37 +01:00
env:
- name: RCLONE_CONFIG_DESTINATION_ACL
value: private
- name: RCLONE_CONFIG_DESTINATION_TYPE
value: s3
- name: RCLONE_CONFIG_DESTINATION_ENDPOINT
value: s3.sto3.safedc.net
- name: RCLONE_CONFIG_DESTINATION_PROVIDER
value: Ceph
2025-02-07 15:33:39 +01:00
volumeMounts:
- name: backup-storage
mountPath: /backup_storage
mountPropagation: HostToContainer
2025-02-07 15:46:47 +01:00
- name: ipc-storage
2025-02-07 15:44:49 +01:00
mountPath: /backup_ipc
2025-02-07 15:33:39 +01:00
- name: mount-container
image: rclone/rclone:1.69.0
2025-02-07 15:44:49 +01:00
args: ["mount", "--allow-non-empty", "source:$(BUCKET)", "/backup_storage"]
2025-02-07 15:33:39 +01:00
securityContext:
privileged: true
env:
2025-02-07 13:21:37 +01:00
- name: RCLONE_CONFIG_SOURCE_ACL
value: private
- name: RCLONE_CONFIG_SOURCE_TYPE
value: s3
- name: RCLONE_CONFIG_SOURCE_ENDPOINT
value: s3.sto4.safedc.net
- name: RCLONE_CONFIG_SOURCE_PROVIDER
value: Ceph
2025-02-07 15:33:39 +01:00
volumeMounts:
- name: backup-storage
mountPath: /backup_storage
mountPropagation: Bidirectional
2025-02-07 15:46:47 +01:00
- name: ipc-storage
2025-02-07 15:44:49 +01:00
mountPath: /backup_ipc
2025-02-07 15:50:53 +01:00
livenessProbe:
exec:
2025-02-07 16:07:19 +01:00
command: ["sh", "-c", "if test -f /backup_ipc/stop; then umount /backup_storage; exit 1; fi;"]