diff --git a/backup-testing/restore-test.sh b/backup-testing/restore-test.sh index e66399c..3762272 100755 --- a/backup-testing/restore-test.sh +++ b/backup-testing/restore-test.sh @@ -3,7 +3,7 @@ # k3s in Docker, to prove the backups can be restored. Nothing on the NAS # changes: # - one backup (backups//) and the kopia repositories of the chosen -# namespaces (kopia//) are copied read-only from MinIO with +# namespaces (kopia//) are copied read-only from the NAS with # rclone into a Docker volume. A second Velero on the real bucket could # run kopia maintenance on the same repositories as the cluster's own # - `rclone serve s3` serves that copy to a Velero 1.18.2 in k3s, with a @@ -19,7 +19,7 @@ # Defaults: the newest Completed daily-backup, and ntfy freshrss # actual-budget. Not gatus: a restored Gatus would start sending alerts. # -# It reads Velero's MinIO key from the cluster (velero/cloud-credentials) +# It reads Velero's S3 key from the cluster (velero/velero-s3-credentials) # into a temporary directory, and the copied backup holds every Secret of # the cluster; all of it is deleted at the end. KEEP=1 keeps the test # cluster (kubeconfig in the printed directory) until you run it with @@ -71,14 +71,14 @@ wait_for() { done } -# Endpoint, region and bucket as Velero itself uses them. MinIO answers a -# request signed for the wrong region (rclone defaults to us-east-1) with a -# bare 400 on HEAD. +# Endpoint, region and bucket as Velero itself uses them. The NAS rejects a +# request signed for the wrong region (rclone defaults to us-east-1); MinIO +# did so with a bare 400 on HEAD. if [[ -n ${FROM_VOLUME:-} ]]; then BUCKET=${BUCKET:-velero-backups} else bsl=$(pk -n velero get backupstoragelocations default -o json) - MINIO=${MINIO:-$(jq -r '.spec.config.s3Url' <<<"$bsl")} + S3URL=${S3URL:-$(jq -r '.spec.config.s3Url' <<<"$bsl")} REGION=${REGION:-$(jq -r '.spec.config.region // "us-east-1"' <<<"$bsl")} BUCKET=${BUCKET:-$(jq -r '.spec.objectStorage.bucket' <<<"$bsl")} fi @@ -101,10 +101,10 @@ if [[ -n ${FROM_VOLUME:-} ]]; then docker run --rm -v "$FROM_VOLUME:/from:ro" -v "$VOL:/data" alpine:3.22 cp -a /from/. /data/ else echo "== copy from the NAS (read-only)" -(umask 077; pk -n velero get secret cloud-credentials -o jsonpath='{.data.cloud}' | base64 -d | +(umask 077; pk -n velero get secret velero-s3-credentials -o jsonpath='{.data.cloud}' | base64 -d | awk -F' *= *' '/aws_access_key_id/ {print "RCLONE_CONFIG_NAS_ACCESS_KEY_ID="$2} /aws_secret_access_key/ {print "RCLONE_CONFIG_NAS_SECRET_ACCESS_KEY="$2}' > "$WORK/nas.env" - printf 'RCLONE_CONFIG_NAS_TYPE=s3\nRCLONE_CONFIG_NAS_PROVIDER=Minio\nRCLONE_CONFIG_NAS_ENDPOINT=%s\nRCLONE_CONFIG_NAS_REGION=%s\n' "$MINIO" "$REGION" >> "$WORK/nas.env") + printf 'RCLONE_CONFIG_NAS_TYPE=s3\nRCLONE_CONFIG_NAS_PROVIDER=Other\nRCLONE_CONFIG_NAS_ENDPOINT=%s\nRCLONE_CONFIG_NAS_REGION=%s\n' "$S3URL" "$REGION" >> "$WORK/nas.env") copy() { docker run --rm --env-file "$WORK/nas.env" -v "$VOL:/data" "$RCLONE" copy --stats-one-line "nas:$BUCKET/$1" "/data/$BUCKET/$1"; } copy "backups/$backup" for ns in "${namespaces[@]}"; do copy "kopia/$ns"; done