|
|
@@ -38,20 +38,62 @@ spec:
|
|
|
spec:
|
|
|
template:
|
|
|
spec:
|
|
|
+ initContainers:
|
|
|
+ - name: prepare-wrapper
|
|
|
+ image: busybox
|
|
|
+ command: ["/bin/sh", "-c"]
|
|
|
+ args:
|
|
|
+ - |
|
|
|
+ cat > /shared/wrapper.sh << 'EOF'
|
|
|
+ #!/bin/sh
|
|
|
+ # Execute the original entrypoint with all arguments
|
|
|
+ /usr/local/bin/rclone "$@"
|
|
|
+ # Capture the exit code
|
|
|
+ echo $? > /shared/exit-code
|
|
|
+ EOF
|
|
|
+ chmod +x /shared/wrapper.sh
|
|
|
+ volumeMounts:
|
|
|
+ - name: shared-data
|
|
|
+ mountPath: /shared
|
|
|
containers:
|
|
|
- - args: ["sync", "--verbose", "--verbose", "--cache-workers", "4", "--transfers", "4", "--retries", "32", "--oos-attempt-resume-upload", "--oos-leave-parts-on-error", "/data/repo", "oos:backup"]
|
|
|
+ - name: rclone
|
|
|
image: rclone/rclone:1.68
|
|
|
+ command: ["/shared/wrapper.sh"]
|
|
|
+ args: ["sync", "--verbose", "--verbose", "--cache-workers", "4", "--transfers", "4", "--retries", "32", "--oos-attempt-resume-upload", "--oos-leave-parts-on-error", "/data/repo", "oos:backup"]
|
|
|
imagePullPolicy: IfNotPresent
|
|
|
- name: rclone-cli
|
|
|
volumeMounts:
|
|
|
- - name: restic-repo-vol
|
|
|
- mountPath: /data/repo
|
|
|
- - name: rclone-conf-vol
|
|
|
- mountPath: /config/rclone
|
|
|
- - name: oci-conf-vol
|
|
|
- mountPath: /config/oci
|
|
|
- - name: oci-api-key-vol
|
|
|
- mountPath: /config/oci-keys
|
|
|
+ - name: restic-repo-vol
|
|
|
+ mountPath: /data/repo
|
|
|
+ - name: rclone-conf-vol
|
|
|
+ mountPath: /config/rclone
|
|
|
+ - name: oci-conf-vol
|
|
|
+ mountPath: /config/oci
|
|
|
+ - name: oci-api-key-vol
|
|
|
+ mountPath: /config/oci-keys
|
|
|
+ - name: shared-data
|
|
|
+ mountPath: /shared
|
|
|
+ - name: notify
|
|
|
+ image: curlimages/curl
|
|
|
+ command: ["/bin/sh"]
|
|
|
+ args:
|
|
|
+ - -c
|
|
|
+ - |
|
|
|
+ while [ ! -f /shared/exit-code ]; do sleep 1; done
|
|
|
+
|
|
|
+ AUTH_HEADER="Authorization: Bearer tk_up3glyzhhojl1w5lt32jq5vqjzdgb"
|
|
|
+ URL="http://ntfy/backup"
|
|
|
+ MESSAGE="Remote restic backup"
|
|
|
+
|
|
|
+ if [ "$(cat /shared/exit-code)" -eq 0 ]; then
|
|
|
+ STATUS="was successful"
|
|
|
+ else
|
|
|
+ STATUS="FAILED"
|
|
|
+ fi
|
|
|
+
|
|
|
+ curl -X POST -H "$AUTH_HEADER" -d "${MESSAGE} ${STATUS}." "$URL"
|
|
|
+ volumeMounts:
|
|
|
+ - name: shared-data
|
|
|
+ mountPath: /shared
|
|
|
volumes:
|
|
|
- name: restic-repo-vol
|
|
|
hostPath:
|
|
|
@@ -72,6 +114,8 @@ spec:
|
|
|
- name: oci-api-key-vol
|
|
|
secret:
|
|
|
secretName: rclone-remote-backup-api-key
|
|
|
+ - name: shared-data
|
|
|
+ emptyDir: {}
|
|
|
restartPolicy: Never
|
|
|
nodeSelector:
|
|
|
kubernetes.io/hostname: raspberrypi4
|