Gitea: Import repositories from broken gitea

Created on 27 Feb 2019  ·  5Comments  ·  Source: go-gitea/gitea

  • 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

kinquestion

Most helpful comment

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 [email protected]: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

All 5 comments

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

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.

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 [email protected]: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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mirhec picture mirhec  ·  3Comments

Fastidious picture Fastidious  ·  3Comments

jorise7 picture jorise7  ·  3Comments

lunny picture lunny  ·  3Comments

kifirkin picture kifirkin  ·  3Comments