DEV Community

Ara
Ara

Posted on

LifeHack Gitea to Forgejo

The Story

The story is easy , I just wanted to move from Gitea, which I was using for several years, to newly forked Forgejo. Just because The licencing and maintenance of Forgejo looked better for me.

The Challenge

The latest version of forgejo (14.0.3 at the moment of writing this article) not supported migration from the latest version of Gitea at that moment.

Surprisingly only because conflict in database versions. So what I did is :

  • Downloaded newest version of Forgejo.
  • Stopped Gitea.
  • Changed database version to value which is supported for official migration.
  • Started Forgejo with config file of Gitea

I'm managing forgejo/gitea service via systemd and use MySQL as database, but I'm sure that the same procedure is applicable for other databases and service management tools.

Systemd unit /etc/systemd/system/git.service:

[Unit]
Description=Gogs GIT
Documentation=https://forgejo.org/
Wants=network-online.target
After=network-online.target

[Service]
User=git
Group=git
Environment="START_SSH_SERVER=true"
Environment="SSH_PORT=2222"
PIDFile=/var/run/gitea.pid
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/opt/GIT/gitea/gitea web
WorkingDirectory=/opt/GIT/gitea
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=2
StartLimitBurst=3
TasksMax=infinity

[Install]
WantedBy=multi-user.target

Enter fullscreen mode Exit fullscreen mode

Here /opt/GIT/gitea/gitea is just a symlink to actual binary , it was gitea-1.25.5-linux-amd64 now it is gitea -> forgejo-14.0.3-linux-amd64.

  • Stop gitea: systemctl stop git.service,
  • Delete soft link: rm /opt/GIT/gitea/gitea
  • Make new link: cd /opt/GIT/gitea/ && ln -s forgejo-14.0.3-linux-amd64 gitea
  • Edit database with following query: UPDATE version SET version=301
  • Start forgejo: systemctl start git.service

Forgejo starts the standard DB migrate/upgrade procedure, 'thinking' that it's upgrading from supported version.

After few seconds Forgejo was up and running as it should, with fully migrated projects, tasks and everything that was in Gitea instance.

Top comments (0)