You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4.0 KiB

Migrating from Gogs 0.13 to Gitea

In short...it is not possible to directly migrate from Gogs 0.13 to Gitea. While methods were published to do this from 0.11; the database structure has apparently changed entirely too much to be imported.

This is not a direct migration

You will lose some things in doing this; primarily you'll lose all your existing users and issues unless you use external issue tracking. If you have a large number of users and repositories, this is not a good solution sadly.

Your repositories and repository-data however, remains intact.

It may be possible to have gogs export the database to a common format. I did read where it can export to a JSON file; all you would need to do is reimport that in to a format Gitea understands.

This Is How I Migrated git.pickmy

Pre-Installation

Stop the gogs service:

sudo systemctl stop gogs
sudo systemctl disable gogs

Move the git user home directory and create new one:

sudo mv /home/git /home/gogs_old
mkdir /home/git

Copied some needed files in to that directory:

sudo mv /home/gogs_old/.bashrc /home/git/.bashrc
sudo mv /home/gogs_old/.profile /home/git/.profile
sudo mv /home/gogs_old/.gitconfig /home/git/.gitconfig

Install Gitea

Mostly taken from their documentation...we already have a git user setup thanks to having run gogs.

sudo su - git
wget https://dl.gitea.com/gitea/1.19/gitea-1.19-linux-amd64
chmod +x gitea-1.19-linux-amd64
wget https://dl.gitea.com/gitea/1.19/gitea-1.19-linux-amd64.asc
gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
gpg --verify gitea-1.18.5-linux-amd64.asc gitea-1.18.5-linux-amd64
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea/
sudo chmod -R 750 /var/lib/gitea/
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
sudo cp gitea-1.19-linux-amd64 cp gitea /usr/local/bin/gitea

Configure the gitea.service file:

wget https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service
sudo mv gitea.service /etc/systemd/system/gitea.service
sudo nano /etc/systemd/system/gitea.service

Verify all the various options are to your liking for the .service.

sudo systemctl enable gitea
sudo systemctl start gitea

The reverse proxy configuration for gogs in nginx is valid, so you should just have to visit your URL and setup gitea in the browser.

Additional Configuration

By default Gitea makes all repositories private. If this is not how you ran your gogs, then you'll need to edit /etc/gitea/app.ini:

[repository]
ROOT = /var/lib/gitea/data/gitea-repositories
FORCE_PRIVATE = false
DEFAULT_PRIVATE = public

Unlike gogs, Gitea does not use /home/git as it's default home path. This can break a lot of githook scripts if you were using them. Normally you can specify the working directory and drop the .gitconfig in there according to docs; but I instead just pointed it to the old directory. They say this is not recommended...but it's how I was running before. This literally had me pulling my hair out for a while but the guys on their Discord pointed me to this and I thank them.

[git]
HOME_PATH = /home/git

You can also adjust other configuration options at this time. Their (Configuration Cheat Sheet)[https://docs.gitea.io/en-us/config-cheat-sheet/] is worth taking a look at.

Now stop gitea.

sudo systemctl stop gitea

Copy and claim orphened repositories

sudo mv /home/gogs_old/gogs-repositories /var/lib/gitea/data/gitea-repositories

Make sure git owns the directory

sudo chown git:git /var/lib/gitea/data/gitea-repositories

Start up Gitea

sudo systemctl start gitea

Log in as your admin user, click site administration, select Repositores. Click the "Unadopted Repositories" button.

This should find all the repositories and put them in gitea. You'll need to verify they're owned by the original owners and organizations.

You may need to go through and adjust privacy settings for repositories. The config option above makes public the default; so all imported repositories will be public.