Bottom line: Forgejo is a drop-in binary replacement for Gitea, and the correct way to migrate is to stop the service, swap the binary, let Forgejo run its schema migrations on the existing database, then verify with forgejo doctor and a manual checklist — not to export and re-import repositories.

Gitea and Forgejo share the same database schema lineage, the same app.ini format, and the same work-path layout. That means migration is mostly an upgrade operation: you keep the database, keep the repositories on disk, and replace the executable. Pull requests, issues, labels, milestones, review comments, and the merge state of every branch all live in the database and survive untouched. The dump/restore tooling exists for backup and for moving between hosts, and you should use it as a safety net before the swap, not as the migration mechanism itself. The one real constraint is version: Forgejo transparently supports upgrades from Gitea up to and including v1.22, and that path goes through Forgejo v10.0.x first.

Know your starting version before you touch anything

Forgejo’s upgrade guide is explicit about the supported path. Gitea v1.22.x and below can go straight to Forgejo v10.0.x. Anything above Forgejo v10.0.x goes to a later Forgejo release. If you are on Gitea 1.21 or 1.22, you are in the clean lane. If you are on something older, upgrade Gitea within its own series first until you reach 1.22.x, then cross over.

Check the running version and the paths it uses:

1
2
sudo -u git /usr/local/bin/gitea --version
sudo -u git /usr/local/bin/gitea help | head -40

Do not use forgejo help or gitea help to discover CustomPath. The upgrade guide says to read it from the Site administration panel’s configuration tab while logged in as an admin. The CLI defaults can be wrong if the binary was built with different compile-time paths, and getting CustomPath wrong means you migrate the wrong app.ini.

Record three things: the Gitea version string, the absolute path to app.ini, and the database backend. The backend determines your backup procedure.

Backend Backup command Restore command Notes for migration
SQLite sqlite3 gitea.db ".backup '/backup/gitea.db'" copy file back, fix ownership Single file; stop the service first or use .backup for a consistent snapshot
PostgreSQL pg_dump -Fc -U gitea gitea > /backup/gitea.dump pg_restore -U gitea -d gitea /backup/gitea.dump Schema is migrated in place by Forgejo; restore only on rollback
MySQL/MariaDB mysqldump --single-transaction -u gitea -p gitea > /backup/gitea.sql mysql -u gitea -p gitea < /backup/gitea.sql Same in-place migration behaviour

Take a full backup, including the dump

The upgrade guide states a full backup is a requirement when moving to a new stable release and a good precaution for minor and patch releases. For a migration you treat it as mandatory. Two layers: the database-level backup above, and Forgejo’s own dump, which captures repositories, attachments, LFS objects, and configuration in one archive.

1
2
3
4
5
6
sudo systemctl stop gitea

sudo -u git /usr/local/bin/gitea dump \
--config /etc/gitea/app.ini \
--type full \
--file /backup/gitea-pre-forgejo-$(date +%F).zip

--type full includes the database, repositories, and data directory. On a large instance this takes a while and produces a big file; that is the point. Verify the archive lists cleanly (unzip -l) and that its size is in the range you expect from your repository count. If your instance is tens of gigabytes, expect the dump to run for a substantial fraction of an hour and size the backup volume accordingly.

Keep the service stopped from here until the swap is verified. Do not run Forgejo against a database that Gitea is still writing to.

Swap the binary and let the schema migrate

Download the Forgejo release matching your target. For the Gitea 1.22 path, that is Forgejo v10.0.x. Install it alongside the old binary rather than overwriting, so rollback is a symlink change.

1
2
3
4
5
6
cd /tmp
curl -L -o forgejo \
https://codeberg.org/forgejo/forgejo/releases/download/v10.0.3/forgejo-10.0.3-linux-amd64
chmod +x forgejo
sudo mv /usr/local/bin/gitea /usr/local/bin/gitea.pre-forgejo
sudo install -o root -g root -m 755 /tmp/forgejo /usr/local/bin/forgejo

Point your systemd unit at the new path. If the unit uses ExecStart=/usr/local/bin/gitea web, either edit it to /usr/local/bin/forgejo web or leave a symlink. Editing the unit is clearer for the next person. Then start the service and watch the log — the first start is where migrations run.

1
2
3
sudo systemctl daemon-reload
sudo systemctl start forgejo
sudo journalctl -u forgejo -f

Forgejo applies its schema migrations automatically on startup. On a mid-sized instance (a few hundred repositories, tens of thousands of issues) this completes in well under a minute; on a very large one it can take several minutes. Do not interrupt it. If the process exits non-zero, read the migration error before doing anything else — the database is now in a partially migrated state and your rollback is the backup, not a retry.

Before declaring success, flush the queues. The upgrade guide calls this out specifically because queues hold serialized data that is not guaranteed to be backward compatible between versions:

1
2
sudo -u git /usr/local/bin/forgejo manager flush-queues \
--config /etc/gitea/app.ini

If it times out, rerun with a more generous --timeout. Then run the doctor:

1
2
3
sudo -u git /usr/local/bin/forgejo doctor check --all \
--config /etc/gitea/app.ini \
--log-file /tmp/doctor.log

The guide’s requirement is that it reports no problems. Treat any finding as a blocker and resolve it before you let users back in.

Verify the things that matter, not just the login page

A working login page proves almost nothing. The upgrade guide recommends a written checklist of a typical use case so you do not skip steps. Mine, in order:

  • Log in as an admin and open the Site administration configuration tab; confirm CustomPath, database settings, and repository root are what you expect.
  • Open a repository with an open pull request that has review comments. Confirm the diff renders, the comments are attached to the right lines, and the merge button state is correct.
  • Check a closed/merged pull request and confirm the merge commit reference is intact.
  • Confirm issues, labels, and milestones count matches what you remember; spot-check a few assignees.
  • Push a commit over SSH and over HTTPS to confirm keys, tokens, and hooks still work.
  • Trigger a webhook and confirm delivery.
  • Check LFS: clone a repository that uses it and confirm objects download.
  • Open the Actions tab if you use it and confirm runners reconnect.

Pull requests are the fragile part in people’s minds, and they are exactly the part that survives, because they are rows in the database and the schema migration preserves them. What breaks after a migration is almost always configuration and external integration, not data.

Pitfalls and how to diagnose them

Wrong CustomPath. Forgejo starts with defaults, finds an empty database, and presents the install page. Symptom: your instance looks brand new. Diagnosis: check the configuration tab path you recorded earlier and pass --custom-path and --config explicitly. Do not guess from help output.

Skipped version boundary. Going from Gitea 1.22 directly to a Forgejo release newer than v10.0.x is not the documented path. Symptom: migration errors on startup or a doctor failure. Diagnosis: read the release notes for the version you installed and step through v10.0.x first.

Dirty queues. Serialized queue payloads from the old version get processed by the new one. Symptom: stuck background jobs, missing webhook deliveries, or odd notification behaviour. Diagnosis: forgejo manager flush-queues, rerun with a larger --timeout if it times out.

Custom templates and CSS. Forgejo does not migrate your customized template overrides. Symptom: broken layout or missing custom footer after login. Diagnosis: diff your custom/templates against the new release’s templates and reapply. The guide tells you to analyse the template patches manually.

Docker version too old. If you run the container, the guide requires Docker 20.10.6 or newer, and warns that older versions produce failures that look unrelated to Docker. Symptom: inexplicable errors in an otherwise correct setup. Diagnosis: docker version and upgrade the engine.

SELinux and file ownership. The new binary may carry a different context, or the dump restore may leave files owned by the wrong user. Symptom: permission denied on the repository root. Diagnosis: check ls -lZ on the repo directory and the service unit’s User=.

Log level too low to see anything. When something is wrong, raise it. The guide’s config block sets LEVEL =debug, MODE =console,file, ENABLE_XORM_LOG =true, and separate router and xorm log files. Add it to app.ini, restart, and read the files rather than the journal.

FAQ

Can I keep my existing database, or do I have to export and re-import?

Keep it. Forgejo runs its migrations against the existing schema on first start. Exporting and re-importing is for moving hosts or restoring after a failure, not for the migration itself.

Will my pull requests, review comments, and merge history survive?

Yes. They are database rows, and the migration preserves them. Verify with the checklist anyway, particularly on pull requests with inline review comments.

What is the correct version path from Gitea 1.22?

Gitea up to and including v1.22.x goes to Forgejo v10.0.x, then from v10.0.x to any later Forgejo release. Do not skip the v10.0.x step.

Do I need to stop the service during the swap?

Yes. Stop Gitea before taking the dump, keep it stopped while you replace the binary, and start Forgejo only when the old process is gone. Two processes on one database is how you corrupt it.

How do I roll back if the migration fails?

Stop Forgejo, restore the database backup, put the old binary back at its original path, restore the systemd unit, and start it. This is why you keep gitea.pre-forgejo and a verified dump rather than overwriting in place.

How long should I wait before trusting the new instance?

Until forgejo doctor check --all reports no problems and your manual checklist passes end to end. The upgrade guide is blunt about this: restoring the pre-upgrade backup is easy immediately after, but a problem discovered days later cannot be fixed by rollback without losing everything since.