How to migrate Gitea
Recently, I buy a new server in Ali cloud HK, whose latency is very low visiting from China mainland. So I decide to migrate all service from RN US LA to this new server.
The first thing is my blog. As it is based on Gitea, so I need to migrate Gitea first. Let’s start it.
How to migrate Gitea
Now we give alias name to two server.
Old server: server A
New server: server B
Environment:
1 | Server A: |
Install a brand new Gitea on Server B following installation tutorial in my blog. Please use the same password when create database user in order to avoid bug.
Log in server A as root.
1
2
3
4
5cd /etc/gitea/
gitea dump --config app.ini # use official command to back up needed file.
exit
scp /etc/gitea/gitea-dump-1716769046.zip root@server_B:~/ # maybe your file name is different with me, just use yours.
exitLog in server B as root.
1
2
3
4
5
6
7
8
9
10apt update
apt install unzip
unzip gitea-dump-1716769046.zip
mv app.ini /etc/gitea/app.ini
rm -rf /var/lib/gitea/data # delete default file in new Gitea
mv data /var/lib/gitea/
mkdir /var/lib/gitea/data/gitea-repositories
mv repos/* /var/lib/gitea/data/gitea-repositories/
psql -U gitea -d giteadb < gitea-db.sql
vim /etc/gitea/app.ini # edit the following infomation as yours.1
2
3
4
5[server]
SSH_DOMAIN = gitea.your.domain
DOMAIN = gitea.your.domain
HTTP_PORT = 3000
ROOT_URL = https://gitea.your.domain/1
2chown -R git:git /etc/gitea/app.ini /var/lib/gitea
service gitea restartLog into new Gitea and delete old ssh keys and re-add them as gitea dump won’t migrate your ssh keys. All done. Happy coding with your new Gitea!