From cb78ccdb0bfae27fdb6727e127d5e64dff963512 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 01:38:24 +0900 Subject: [PATCH] feat(backup): store the Gitea version next to each dump A Gitea dump must be restored with the Gitea version that wrote it, and a restore checks the repository count against the dump. Neither was recorded outside the archive, so the restore runbook had nothing to compare with. Upload a small .meta file with each dump: creation time, the Deployment image, the gitea --version output and the repository count. docs/runbooks/gitea-restore.md reads it. Risk: none for the backup itself; the file holds no secret. Verification: bash -n; kubectl -n gitea exec deploy/gitea -c gitea -- gitea --version prints "gitea version 1.27.0 built with ..." on the desktop, so the third field is the version. --- scripts/backup/gitea-backup.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/backup/gitea-backup.sh b/scripts/backup/gitea-backup.sh index c0c96f5..32de28b 100644 --- a/scripts/backup/gitea-backup.sh +++ b/scripts/backup/gitea-backup.sh @@ -41,8 +41,15 @@ repos="$(grep -c -E '^repos/[^/]+/[^/]+\.git/HEAD$' "$work/list.txt" || true)" (( repos > 0 )) || hb_fail "the dump has no repositories" sha256sum "$work/$archive" | awk '{print $1}' >"$work/$archive.sha256" size="$(stat -c %s "$work/$archive")" +# What a restore must match: restore with the same Gitea version (docs/runbooks/gitea-restore.md). +{ + echo "created=$ts" + echo "gitea_image=$(kubectl -n gitea get deploy gitea -o jsonpath='{.spec.template.spec.containers[0].image}')" + echo "gitea_version=$(kubectl -n gitea exec deploy/gitea -c gitea -- gitea --version 2>/dev/null | awk '{print $3}')" + echo "repositories=$repos" +} >"$work/$archive.meta" -hb_mc "$work" cp --quiet "/work/$archive" "/work/$archive.sha256" "backup/$AISTOR_BUCKET/gitea/" >/dev/null +hb_mc "$work" cp --quiet "/work/$archive" "/work/$archive.sha256" "/work/$archive.meta" "backup/$AISTOR_BUCKET/gitea/" >/dev/null hb_mc "$work" stat "backup/$AISTOR_BUCKET/gitea/$archive" >/dev/null trap - ERR