tenseleyflow/shithub / ea75041

Browse files

backup-daily: sudo -u postgres for pg_dump and skip rclone bucket check

Authored by espadonne
SHA
ea75041562d26344fbcf614fc9d0140dde4455f2
Parents
f65b942
Tree
2375a79

1 changed file

StatusFile+-
M deploy/postgres/backup-daily.sh 7 2
deploy/postgres/backup-daily.shmodified
@@ -21,13 +21,18 @@ NAME="${DB}-${STAMP}.dump"
2121
 
2222
 mkdir -p "$LOCAL_DIR"
2323
 
24
-pg_dump --format=custom --compress=9 --no-owner --no-privileges \
24
+# pg_dump as the postgres user via local-socket peer auth.
25
+# Cron runs this script as root; sudo handles the user switch.
26
+sudo -u postgres pg_dump --format=custom --compress=9 --no-owner --no-privileges \
2527
         --file="$LOCAL_DIR/$NAME" "$DB"
2628
 
2729
 # Verify the dump is structurally sound before we ship it.
2830
 pg_restore --list "$LOCAL_DIR/$NAME" >/dev/null
2931
 
30
-rclone --config /root/.config/rclone/rclone.conf \
32
+# --s3-no-check-bucket: skip the GetBucketLocation pre-check that
33
+# requires a permission our scoped-RW Spaces key doesn't grant.
34
+# The actual PUT works fine on a key with bucket-level readwrite.
35
+rclone --config /root/.config/rclone/rclone.conf --s3-no-check-bucket \
3136
        copyto "$LOCAL_DIR/$NAME" "$BUCKET/daily/$(date -u +%Y/%m/%d)/$NAME"
3237
 
3338
 # Local retention: keep the last 7 dumps; bucket lifecycle handles