Update database from Git Repositories #4220

Closed
opened 2025-11-02 05:42:50 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @tcyrus on GitHub (Nov 1, 2019).

  • Gitea version (or commit ref): 1.9.2
  • Git version: N/A
  • Operating system: Ubuntu
  • 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:

Description

My database server had an issue unrelated to Gitea, but I lost some of the database records. I restored a backup of the database, but some of the repositories are missing from this copy.

I was wondering if there was an admin command to do the reverse of "Reinitialize all missing Git repositories for which records exist", where it would "Reinitialize all missing records for which Git repositories exist".

Originally created by @tcyrus on GitHub (Nov 1, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) 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): 1.9.2 - Git version: N/A - Operating system: Ubuntu - Database (use `[x]`): - [X] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: ## Description My database server had an issue unrelated to Gitea, but I lost some of the database records. I restored a backup of the database, but some of the repositories are missing from this copy. I was wondering if there was an admin command to do the reverse of "Reinitialize all missing Git repositories for which records exist", where it would "Reinitialize all missing records for which Git repositories exist".
GiteaMirror added the type/questionissue/confirmed labels 2025-11-02 05:42:50 -06:00
Author
Owner

@guillep2k commented on GitHub (Nov 1, 2019):

You can enable IMPORT_LOCAL_PATHS = true in app.ini and manually import those repositories. They will be created anew in the database; no issues/PRs/labels/etc will exist but the code will be there. For this to work you must first move them out of their current location (i.e. from gitea-repositories/{owner}/... to another directory).
I know it isn't much, but may be it will help.

@guillep2k commented on GitHub (Nov 1, 2019): You can enable `IMPORT_LOCAL_PATHS = true` in `app.ini` and manually import those repositories. They will be created anew in the database; no issues/PRs/labels/etc will exist but the code will be there. For this to work you must first move them out of their current location (i.e. from `gitea-repositories/{owner}/...` to another directory). I know it isn't much, but may be it will help.
Author
Owner

@guillep2k commented on GitHub (Nov 1, 2019):

This, however, could be an interesting function for a Gitea utility to have.

@guillep2k commented on GitHub (Nov 1, 2019): This, however, could be an interesting function for a Gitea utility to have.
Author
Owner

@zeripath commented on GitHub (Nov 1, 2019):

Yeah I think we should make it possible recover data - however, it's a slightly difficult situation. With a completely brand new Gitea do you create users for each of the recovered repositories? - but they might have meant to be organisations so this is probably not correct. So you should probably leave it till users are created - and then restore?

@zeripath commented on GitHub (Nov 1, 2019): Yeah I think we should make it possible recover data - however, it's a slightly difficult situation. With a completely brand new Gitea do you create users for each of the recovered repositories? - but they might have meant to be organisations so this is probably not correct. So you should probably leave it till users are created - and then restore?
Author
Owner

@guillep2k commented on GitHub (Nov 1, 2019):

Yeah I think we should make it possible recover data - however, it's a slightly difficult situation. With a completely brand new Gitea do you create users for each of the recovered repositories? - but they might have meant to be organisations so this is probably not correct. So you should probably leave it till users are created - and then restore?

It's pretty easy: recreate those that have a matching user, report those that don't. 😁

@guillep2k commented on GitHub (Nov 1, 2019): > > > Yeah I think we should make it possible recover data - however, it's a slightly difficult situation. With a completely brand new Gitea do you create users for each of the recovered repositories? - but they might have meant to be organisations so this is probably not correct. So you should probably leave it till users are created - and then restore? It's pretty easy: recreate those that have a matching user, report those that don't. 😁
Author
Owner

@stale[bot] commented on GitHub (Jan 1, 2020):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 1, 2020): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@lunny commented on GitHub (Jan 1, 2020):

Since push to create feature has been implemented, I think we can close this now.

@lunny commented on GitHub (Jan 1, 2020): Since `push to create feature` has been implemented, I think we can close this now.
Author
Owner

@stale[bot] commented on GitHub (Mar 1, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Mar 1, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4220