go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.23k stars 5.32k forks source link

Issues & repos cannot be accessed after restoring Gitea backup #31084

Open Android-X13 opened 1 month ago

Android-X13 commented 1 month ago

Description

Gitea backup is created via one of the following commands (I have tested both):

sudo -u git gitea dump -c /etc/gitea/app.ini

sudo -u git gitea dump --database sqlite3 -c /etc/gitea/app.ini

Restoration commands:

mv gitea-dump/app.ini /etc/gitea/app.ini
mv gitea-dump/custom/* /var/lib/gitea/custom/
mv gitea-dump/data/* /var/lib/gitea/data/
mv gitea-dump/log/* /var/lib/gitea/log/
mv gitea-dump/repos/* /var/lib/gitea/data/gitea-repositories/
sqlite3 /var/lib/gitea/data/gitea.db < gitea-dump/gitea-db.sql

I can see all the issues in the Issues tab and all the repositories in the Explore tab. However when clicking on either an issue or a repository I get the following message:

The Git data underlying this repository cannot be read. Contact the administrator of this instance or delete this repository.

Gitea Version

1.21.11

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Binary download, systemd

Database

SQLite

Doublefire-Chen commented 1 month ago

Same issue

Doublefire-Chen commented 1 month ago

Hi, bro, I have solved my issue. https://github.com/go-gitea/gitea/issues/31093#issuecomment-2132775579, hope this could help you too.

Android-X13 commented 1 month ago

In my case I did use the correct path despite the outdated docs:

mv gitea-dump/repos/* /var/lib/gitea/data/gitea-repositories/

However the gitea dump command had backed up the directory structure of the repositories incorrectly.

I had 2 organizations, one of which was empty (with no repos), and the following directory structure:

/var/lib/gitea/data/gitea-repositories/org1/
/var/lib/gitea/data/gitea-repositories/org2/

The gitea dump command skipped the creation of the org directories, apparently because one of them (org2) was empty, and put all .git files of org1 directly under the repos directory. This wouldn't happen if org2 had at least one repository.

I fixed it manually but since this is a bug of the gitea dump command I'm leaving the issue open.

vjm commented 2 weeks ago

i had this same issue as @Android-X13 when no organizations existed and only one admin user.