Error 500 on repositories after backup and restore

I use a docker image “gitea/gitea:1.17-rootless” to create my docker environment. I recently needed to migrate my environment to a new server. When restoring the backup to a new installation the repositories became inaccessible. When I click on a repository a 500 error is shown.

Backup and restore documentation for rootless containers appears to be out of date.

With the command below I generated the backup of my gitea installation in docker:

docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea") bash -c '/usr/local/bin/gitea  dump -c /etc/gitea/app.ini --file /tmp/gitea-dump.zip'
  • The gitea-dump.zip file has the following content:

app.ini
data/
gitea-db.sql
repos/

I did a fresh install of gitea using docker and did the following steps:

  • Mysql database restore:
docker cp gitea-db.sql giteadb:/gitea-db.sql
docker exec -it giteadb /bin/bash
mysql -u gitea -v gitea -p < gitea-db.sql
  • Restore Gitea files with root user:
docker exec --user root -it cont-gitea-01 /bin/bash
cd /
unzip gitea-dump.zip -d /backup
cp backup/app.ini /etc/gitea/app.ini
cp -R backup/data/* /var/lib/gitea
cp -R backup/repos/* /var/lib/gitea/git/repositories
chown -R git:git /etc/gitea/app.ini /var/lib/gitea

Running the hooks with the git user:

docker exec -it gitea /bin/bash
/usr/local/bin/gitea -c '/etc/gitea/app.ini' admin regenerate hooks

Restored repository error:

I made some changes to the file copy commands and found that when I used “*” the repositories were copied but not the user folder that owns the repositories.

example:

The copied repository path was:

/backup/repos/campos/myrepo.git/

However, when copying, only myrepo.git was copied and not campos/myrepo.git/

Also, it was not necessary to generate hooks.

Updated commands

  • Restoring application files:

docker cp gitea-dump.zip gitea:/gitea-dump.zip
docker exec --user root -it gitea mkdir /backup
docker exec --user root -it gitea /bin/bash
unzip /gitea-dump.zip -d /backup
cp /backup/app.ini /etc/gitea/app.ini
cp -R /backup/data/. /var/lib/gitea
cp -R /backup/repos/. /var/lib/gitea/git/repositories
chown -R git:git /etc/gitea/app.ini /var/lib/gitea

  • Database restore:

docker cp gitea-db.sql giteadb:/gitea-db.sql
docker exec -it giteadb /bin/bash
mysql -u gitea gitea -p < gitea-db.sql

  • Restarting containers:

docker-compose restart