fix(forte-drop-pg-backup): upload with rclone, the mc image can no longer be pulled
scan.yaml / test (pull_request) Successful in 8s
scan.yaml / test (pull_request) Successful in 8s
quay.io/minio/mc answers 401 for every tag since MinIO made the repository
private, so the upload container cannot be pulled. Same cause and fix as the
Gitea backup (90b8e6f): rclone/rclone:1.75.2, copy to s3:drops/_pgbackups/
and prune that prefix only with delete --min-age 30d.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# Dumps to s3://drops/_pgbackups/ (the `_` prefix is collision-proof: app slugs match
|
# Dumps to s3://drops/_pgbackups/ (the `_` prefix is collision-proof: app slugs match
|
||||||
# /^[a-z0-9][a-z0-9-]{0,62}$/ and can never start with `_`). Retains 30 days.
|
# /^[a-z0-9][a-z0-9-]{0,62}$/ and can never start with `_`). Retains 30 days.
|
||||||
#
|
#
|
||||||
# Pod shape: initContainer pg_dump → shared emptyDir → mc upload + retention prune.
|
# Pod shape: initContainer pg_dump → shared emptyDir → rclone upload + retention prune.
|
||||||
# Both images pinned. S3 creds reuse forte-drop-secrets (the app's UpCloud user has
|
# Both images pinned. S3 creds reuse forte-drop-secrets (the app's UpCloud user has
|
||||||
# s3:* on the drops bucket). PG creds from forte-drop-pg-creds.
|
# s3:* on the drops bucket). PG creds from forte-drop-pg-creds.
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
@@ -65,24 +65,38 @@ spec:
|
|||||||
mountPath: /work
|
mountPath: /work
|
||||||
containers:
|
containers:
|
||||||
- name: upload
|
- name: upload
|
||||||
image: quay.io/minio/mc:RELEASE.2024-11-21T17-21-54Z
|
# Was quay.io/minio/mc until MinIO made the mc repository private:
|
||||||
|
# every tag now answers 401 on quay.io and Docker Hub, so the pod
|
||||||
|
# cannot pull it (same cause and fix as cluster-resources/
|
||||||
|
# gitea-backup-cronjob.yaml). rclone is a public, pinned equivalent:
|
||||||
|
# `delete --min-age` replaces `mc rm --older-than`.
|
||||||
|
image: rclone/rclone:1.75.2
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
mc alias set obj "$S3_ENDPOINT" "$S3_KEY" "$S3_SECRET"
|
export RCLONE_CONFIG_S3_ENDPOINT="${S3_ENDPOINT}"
|
||||||
mc cp /work/*.sql.gz "obj/${S3_BUCKET}/_pgbackups/"
|
export RCLONE_CONFIG_S3_ACCESS_KEY_ID="${S3_KEY}"
|
||||||
|
export RCLONE_CONFIG_S3_SECRET_ACCESS_KEY="${S3_SECRET}"
|
||||||
|
# Only ever this prefix: the bucket also holds every drop.
|
||||||
|
DEST="s3:${S3_BUCKET}/_pgbackups/"
|
||||||
|
rclone copy /work "$DEST" --include "*.sql.gz"
|
||||||
echo "uploaded. pruning backups older than 30d:"
|
echo "uploaded. pruning backups older than 30d:"
|
||||||
mc rm --recursive --force --older-than 30d "obj/${S3_BUCKET}/_pgbackups/" || true
|
rclone delete --min-age 30d --use-server-modtime "$DEST" || true
|
||||||
echo "backup retention pass complete"
|
echo "backup retention pass complete"
|
||||||
env:
|
env:
|
||||||
# mc writes its config under $MC_CONFIG_DIR; point it at the shared
|
# rclone wants a writable home for its cache; the root fs is not
|
||||||
# emptyDir (writable by uid 65532 via fsGroup). Without this it tries
|
# writable for uid 65532, the shared emptyDir is (fsGroup).
|
||||||
# to mkdir /.mc on the read-only-to-nonroot root fs -> "mkdir /.mc:
|
- name: HOME
|
||||||
# permission denied" and every run fails before uploading.
|
value: "/work"
|
||||||
- name: MC_CONFIG_DIR
|
- name: RCLONE_CONFIG_S3_TYPE
|
||||||
value: "/work/.mc"
|
value: s3
|
||||||
|
- name: RCLONE_CONFIG_S3_PROVIDER
|
||||||
|
value: Other
|
||||||
|
# Do not call CreateBucket before the first write.
|
||||||
|
- name: RCLONE_S3_NO_CHECK_BUCKET
|
||||||
|
value: "true"
|
||||||
- name: S3_ENDPOINT
|
- name: S3_ENDPOINT
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef: { name: forte-drop-secrets, key: S3_ENDPOINT }
|
secretKeyRef: { name: forte-drop-secrets, key: S3_ENDPOINT }
|
||||||
|
|||||||
Reference in New Issue
Block a user