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
45.07k stars 5.49k forks source link

Import repositories from broken gitea #6205

Closed LunaTheFoxgirl closed 5 years ago

LunaTheFoxgirl commented 5 years ago

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

lunny commented 5 years ago

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

LunaTheFoxgirl commented 5 years ago

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.

saitho commented 5 years ago

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
LunaTheFoxgirl commented 5 years ago

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

TheRojam commented 4 years ago

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