2024-05-08 13:00:41 +00:00
|
|
|
apiVersion: batch/v1
|
|
|
|
kind: CronJob
|
|
|
|
metadata:
|
|
|
|
name: backup
|
|
|
|
spec:
|
|
|
|
schedule: "42 */6 * * *"
|
|
|
|
jobTemplate:
|
|
|
|
spec:
|
|
|
|
completions: 11
|
|
|
|
parallelism: 3
|
|
|
|
completionMode: Indexed
|
|
|
|
ttlSecondsAfterFinished: 300
|
|
|
|
backoffLimitPerIndex: 3
|
|
|
|
template:
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- name: rclone
|
|
|
|
image: rclone
|
|
|
|
command: ["/bin/ash", "-c"]
|
|
|
|
args:
|
|
|
|
- |
|
|
|
|
for bucket in $(cat /config/backup/buckets | head -n $JOB_COMPLETION_INDEX | tail -n 1);
|
|
|
|
do
|
|
|
|
if [ -z "$bucket" ]; then exit 0; fi
|
|
|
|
echo "Syncing bucket $bucket";
|
2024-05-08 13:15:59 +00:00
|
|
|
rclone sync -P \
|
|
|
|
--update \
|
|
|
|
--checksum \
|
|
|
|
--no-traverse \
|
|
|
|
--no-update-modtime \
|
|
|
|
--no-update-dir-modtime \
|
|
|
|
--ignore-errors \
|
|
|
|
-v \
|
|
|
|
"garage:$bucket" "storagebox:garage/$bucket/";
|
2024-05-08 13:00:41 +00:00
|
|
|
done
|
|
|
|
volumeMounts:
|
|
|
|
- name: rclone-config
|
|
|
|
mountPath: /config/rclone
|
|
|
|
- name: backup-config
|
|
|
|
mountPath: /config/backup
|
|
|
|
securityContext:
|
|
|
|
capabilities:
|
|
|
|
drop:
|
|
|
|
- ALL
|
|
|
|
readOnlyRootFilesystem: true
|
2024-05-09 05:22:03 +00:00
|
|
|
restartPolicy: Never
|
2024-05-08 13:00:41 +00:00
|
|
|
volumes:
|
|
|
|
- name: rclone-config
|
|
|
|
secret:
|
|
|
|
secretName: rclone-backup-config
|
|
|
|
defaultMode: 420
|
|
|
|
- name: backup-config
|
|
|
|
configMap:
|
|
|
|
name: backup-config
|
|
|
|
defaultMode: 420
|
|
|
|
securityContext:
|
|
|
|
allowPrivilegeEscalation: false
|
|
|
|
runAsUser: 1000
|
|
|
|
runAsGroup: 1000
|
|
|
|
fsGroup: 1000
|
|
|
|
runAsNonRoot: true
|