Forgejo restore across versions: pin the original release or upgrade during recovery?
0 reputation · 02 Apr 2022, 23:35 UTC
0 reputation · 02 Apr 2022, 23:35 UTC
Forgejo's documented recovery workflow is manual: import the SQL dump, unpack the data directory and repositories, restore app.ini, fix ownership. The open decision is which Forgejo binary to run against the restored database. On first startup the server migrates the schema to the binary's version, and downgrades are unsupported — so restoring a dump from, say, an older LTS release onto the latest version is a one-way move that forfeits any rollback to the original release.
Backups are component-wise (pg_dump, repository root, app.ini with SECRET_KEY and INTERNAL_TOKEN, APP_DATA_PATH), and each dump records the Forgejo version that produced it. LFS objects live on S3, outside the dump. Verification after restore would use forgejo doctor check plus functional tests (clone, LFS fetch, 2FA login). The documentation advises restoring with the same version that produced the backup but does not prescribe whether recovery should also be the upgrade moment.
forgejo doctor check surface migration-related inconsistencies that would distinguish a clean upgrade-restore from a corrupted one?35775 reputation · 03 Apr 2022, 10:49 UTC
Restore onto the exact pinned release that produced the dump, verify the instance, then upgrade as a separate operation. Combining restore and upgrade merges two failure domains — backup fidelity and schema migration — into one irreversible step, and if anything goes wrong you cannot tell which half failed.
The reason this matters is the one-way property you already identified: on first startup, a newer Forgejo binary migrates the database schema to its own version, and downgrades are unsupported. If you point the latest binary at a freshly imported dump and the migration breaks, you have no intermediate known-good state. If you instead restore onto the original version, verify it, and take a fresh dump before upgrading, a failed migration costs you only a re-import, not a forensics session.
Confirmed by the documented workflow: recovery is manual (import dump, unpack data, restore app.ini, fix ownership), and the guidance is to restore with the same version that produced the backup. Likely, based on Forgejo's Gitea lineage: schema migrations run automatically at first startup of a newer binary, are not wrapped in a single transaction, and are not guaranteed to be cleanly resumable after a mid-migration failure. Treat the lineage-derived details as needing confirmation against the release notes for your specific versions.
forgejo doctor check is not a migration validator. It can surface orphaned data, repository/filesystem mismatches, and some database integrity issues, but a clean doctor run does not prove a migration completed correctly. Use it as one signal alongside functional tests, not as the verdict.SECRET_KEY and INTERNAL_TOKEN), and APP_DATA_PATH onto the pinned binary. Fix ownership.forgejo doctor check, then functional tests: clone, push, LFS fetch from S3, 2FA login. Do not skip the LFS fetch — LFS lives outside the dump, so a broken LFS config survives an otherwise clean-looking restore.pg_dump of the verified instance. This is your pre-upgrade recovery point.Mismatched SECRET_KEY or INTERNAL_TOKEN in app.ini silently invalidates sessions and tokens, which looks exactly like a corrupted restore — check this before suspecting the dump. And multi-version upgrades can include slow data migrations on large instances, so rehearse the upgrade in staging with a copy of the production dump to measure downtime before the real recovery.
One caveat: exact migration behavior and doctor subcommands vary by release, so confirm the specifics against the release notes for the versions spanning your dump and target. The one detail that would change this recommendation is how many schema versions separate the dump from the target — a same-major-version gap is low risk either way, while a multi-LTS jump makes the staged path close to mandatory.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.