Import repositories from broken gitea #2985

Closed
opened 2025-11-02 04:56:12 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @LunaTheFoxgirl on GitHub (Feb 27, 2019).

  • Gitea version (or commit ref): cbfc7f5
  • Git version: 2.11.0
  • Operating system: Debian Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
    Wiped logs as they were 22 GB in size

Description

Earlier today my gitea server went offline, when i checked at home the server had run out of space, looking in to it; XORM had created a 22 GB log file breaking the database and making the system very unresponsive.

I deleted all the logs and tried to use the database but as stated, it was corrupted.

How can i import the repositories from the old gitea version to the "fresh" version?
Since i've had to remove the database.

I have the gitea-repositories folder.
...

Screenshots

Originally created by @LunaTheFoxgirl on GitHub (Feb 27, 2019). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): cbfc7f5 - Git version: 2.11.0 - Operating system: Debian Linux - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: Wiped logs as they were 22 GB in size ## Description Earlier today my gitea server went offline, when i checked at home the server had run out of space, looking in to it; XORM had created a 22 GB log file breaking the database and making the system very unresponsive. I deleted all the logs and tried to use the database but as stated, it was corrupted. How can i import the repositories from the old gitea version to the "fresh" version? Since i've had to remove the database. I have the gitea-repositories folder. ... ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/question label 2025-11-02 04:56:12 -06:00
Author
Owner

@lunny commented on GitHub (Feb 28, 2019):

Copy gitea-repositories, data, custom and dump your databases and paste to your new machine.

@lunny commented on GitHub (Feb 28, 2019): Copy `gitea-repositories`, `data`, `custom` and dump your databases and paste to your new machine.
Author
Owner

@LunaTheFoxgirl commented on GitHub (Feb 28, 2019):

Can’t dump database, it is corrupted.

Is there any way to import the raw git repos from gitea-repositories? I don't mind that i'll have to recreate issues and such.

@LunaTheFoxgirl commented on GitHub (Feb 28, 2019): Can’t dump database, it is corrupted. Is there any way to import the raw git repos from gitea-repositories? I don't mind that i'll have to recreate issues and such.
Author
Owner

@saitho commented on GitHub (Mar 19, 2019):

Git repositories are stored on the file system, not in the database. Still the database is used for displaying information on the web interface.

I had a similar issue a few weeks ago. I moved Gitea to another server and forgot to adjust the database configuration. The old server was shut down and my database was lost.

I still had all my repositories on the file system and restored the database by creating a new repository via the web interface and restored the old repository files. It took me some time to figure out that Gitea uses Git hooks to retrieve the changes from commits and show the files on the web interface.

At least that worked for me, running Gitea in a Docker container...

I went into the folder with the repositories and did this for each repository I wanted to restore:

  1. Backup repository folder: mv my-repository.git my-repository.git-bak
  2. Create a new repository with the same name via the Gitea GUI
  3. Remove the folder that is created: rm -rf my-repository.git
  4. Restore the saved repository: cp -R my-repository.git-bak my-repository.git
  5. Set correct permissions: chown -R git:git my-repository.git
  6. Set execution permissions for Git hooks: chmod -R +x my-repository.git/hooks/*
  7. As of right now you should still see no files on the repository page on Gitea
  8. Clone the repository: git clone git@my-gitea.com:user/my-repository.git
  9. Make a change to the local repository and push it: touch test.txt && git add . && git commit -m "Test" && git push -u origin master
  10. Check the repository page on Gitea. The files should show up.
  11. Revert the last commit by changing “pick” on the second line to “d”: git rebase -i HEAD~2 && git push -f
@saitho commented on GitHub (Mar 19, 2019): Git repositories are stored on the file system, not in the database. Still the database is used for displaying information on the web interface. I had a similar issue a few weeks ago. I moved Gitea to another server and forgot to adjust the database configuration. The old server was shut down and my database was lost. I still had all my repositories on the file system and restored the database by creating a new repository via the web interface and restored the old repository files. It took me some time to figure out that Gitea uses Git hooks to retrieve the changes from commits and show the files on the web interface. At least that worked for me, running Gitea in a Docker container... I went into the folder with the repositories and did this for each repository I wanted to restore: 1. Backup repository folder: `mv my-repository.git my-repository.git-bak` 2. Create a new repository with the same name via the Gitea GUI 3. Remove the folder that is created: `rm -rf my-repository.git` 4. Restore the saved repository: `cp -R my-repository.git-bak my-repository.git` 5. Set correct permissions: `chown -R git:git my-repository.git` 6. Set execution permissions for Git hooks: `chmod -R +x my-repository.git/hooks/*` 7. As of right now you should still see no files on the repository page on Gitea 8. Clone the repository: `git clone git@my-gitea.com:user/my-repository.git` 9. Make a change to the local repository and push it: `touch test.txt && git add . && git commit -m "Test" && git push -u origin master` 10. Check the repository page on Gitea. The files should show up. 11. Revert the last commit by changing “pick” on the second line to “d”: `git rebase -i HEAD~2 && git push -f`
Author
Owner

@LunaTheFoxgirl commented on GitHub (Mar 19, 2019):

I've decided to switch back to github for now, though thanks for the suggestion.

@LunaTheFoxgirl commented on GitHub (Mar 19, 2019): I've decided to switch back to github for now, though thanks for the suggestion.
Author
Owner

@TheRojam commented on GitHub (Sep 20, 2020):

I've decided to switch back to github for now, though thanks for the suggestion.

nice.. but that not a solution, that only a workaround... sad

@TheRojam commented on GitHub (Sep 20, 2020): > I've decided to switch back to github for now, though thanks for the suggestion. nice.. but that not a solution, that only a workaround... sad
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2985