Post about migrating Gitea
This commit is contained in:
parent
f790ee26cf
commit
beeaabdf0d
74
src/blog/posts/2024/10/coolify-part-two-migrating-gitea.md
Normal file
74
src/blog/posts/2024/10/coolify-part-two-migrating-gitea.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
---json
|
||||||
|
{
|
||||||
|
"title": "Coolify part two: migrating Gitea",
|
||||||
|
"date": "2024-10-20T08:00:00.109Z",
|
||||||
|
"tags": [
|
||||||
|
"coolify",
|
||||||
|
"gitea",
|
||||||
|
"docker"
|
||||||
|
],
|
||||||
|
"excerpt": "As part of my move over to Coolify, I've migrated my manual Gitea install to one managed by Docker in Coolify"
|
||||||
|
}
|
||||||
|
---
|
||||||
|
|
||||||
|
As part of my [move to Coolify](/post/using-coolify-for-deploying-11ty/), I've now also migrated my Gitea install over. This was a bit of a pain, because the previous install was the binary running directly on the VPS, whereas Coolify runs using Docker containers.
|
||||||
|
|
||||||
|
## Backing up the data
|
||||||
|
|
||||||
|
Firstly, I needed to back up the data. This was pretty straightforward, as the Gitea CLI has a `dump` command that dumps the database, and all relevant files to a zip file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh <user>@<old server ip>
|
||||||
|
gitea -c /var/lib/gitea/app.ini dump
|
||||||
|
```
|
||||||
|
|
||||||
|
I then copied the zip file to the VPS that runs Coolify.
|
||||||
|
|
||||||
|
## Setting up the new Gitea instance
|
||||||
|
|
||||||
|
Next, I started a new Gitea instance in Coolify. Once that had finished deploying, I went to access it at the URL I'd configured - only instead of the Gitea onboarding page, all I got was `Internal Server Error`.
|
||||||
|
|
||||||
|
After checking the logs, I found the following error:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
banner exchange: Connection from 172.22.0.3 port 57082: invalid format
|
||||||
|
```
|
||||||
|
|
||||||
|
After a bit of searching, I found [this Github issue](https://github.com/coollabsio/coolify/issues/985). From what I can tell, the load balancer that Coolify uses is selecting the wrong port for the instance, as it uses the lowest port number that's exposed by the container. So, using the `Edit Compose File` button in the Coolify service configuration, I added the following lines to the Docker compose file:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
labels:
|
||||||
|
- "traefik.http.services.gitea.loadbalancer.server.port=3000"
|
||||||
|
```
|
||||||
|
|
||||||
|
And then saved the file and restarted the service. Once it came back up, I was finally able to access the Gitea instance.
|
||||||
|
|
||||||
|
## Migrating the data
|
||||||
|
|
||||||
|
Now, I needed to migrate the data. Gitea has [some instructions](https://docs.gitea.com/administration/backup-and-restore#restore-command-restore) for doing this. I had a few false starts, but this is the process I eventually followed:
|
||||||
|
|
||||||
|
1. SSH to the new server
|
||||||
|
2. Unzip the gitea dump file
|
||||||
|
3. Edit `app.ini` and changed all of the paths that started with `/var/lib/gitea` to `/data`
|
||||||
|
4. Get the id of the gitea container with `docker ps`
|
||||||
|
5. Copy the files over:
|
||||||
|
1. `docker cp app.ini <container id>:/data/gitea/conf/app.ini`
|
||||||
|
2. `docker cp data <container id>:/data/gitea`
|
||||||
|
3. `docker cp repos <container id>:/data/git/gitea-repositories`
|
||||||
|
6. Access the container with `docker exec -it <container id> /bin/sh` and then `chown -R git:git /data/gitea`
|
||||||
|
7. Restart the container in the Coolify dashboard
|
||||||
|
|
||||||
|
Once it came back up, I was able to access the instance and it functioned more-or-less identically to the previous one.
|
||||||
|
|
||||||
|
## SSH urls
|
||||||
|
|
||||||
|
Initially, using SSH urls for the repositories wasn't working. After some digging, I realised that it's because Coolify exposes the SSH port at `22222` instead of `22`. I _could_ change the port in the Compose file, but instead I just added the following to my `~/.ssh/config` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Host <git server url>
|
||||||
|
Port 22222
|
||||||
|
User git
|
||||||
|
IdentityFile ~/.ssh/id_ed25519
|
||||||
|
```
|
||||||
|
|
||||||
|
And after clearing the old fingerprint from `~.ssh/known_hosts`, I was able to access the repositories over SSH again.
|
Loading…
Reference in New Issue
Block a user