hi all, we use Gitea under docker and it connects to its own seperate postgresDB running in another container.
We had to physically re-locate our servers at our office earlier, and after shutting down the servers and containers etc… the Gitea one seems to have lost all of its data. Is there a way that this database can be rebuilt? I can see in the volume that is mapped to Gitea that there is still repos etc in there. But when we try to login, it just fails with a “user does not exist” error.
I do have a sql dump from 12 months ago (there has been little change config wise in the last 12 months) but there have been a heap of new repos and code in that time. So im not sure what will happen if i do a restore of that sqldump and there is a mismatch of information so to speak.
somewhat specifically in this section of the sqldump
as thats where some of the repos we have are listed, but there are alot more now than whats there. What is shown is mostly valid still, a couple of them have been removed. but there are many more that we want to get back not in there.
I’m in this sticky situation as well. My repos seem to be there in the folder (I have gitea running in container), but my database looks all empty - this could be an yet-unidentified corruption - but no errors, db is "just empty, except I can login and have lost my linked repos, lost my organisation, lost all links to the content. I believe the content (repos, wikis, packages, issues and comments) itself is safe in the directory, which is a relief, but in near future even losing this linking isn’t an option for me. I am planning a gitea for my business production repos soon, and its great to have a DR exercise at hand.
Having said all that, I would like to somehow “rebuild the DB”. I’m okay to lose user info, I can key in again, there was just one org, one admin user and one developer.
PS: I’m pretty sure there has to be a way as earlier this happened once, and I did get back data, without doing anything - so - not sure if this was infra or gitea. I had tried to “docker compose down” on both db and gitea before to make sure data persists, and it did… until now - where I fiddled with my infra network to separate subnets; however, I made sure the hostnames remained the same. All subnets share same DNS I manage.
Gitea is awesome project, please give it some love community, answer calls for help!
Update: I recovered personal repos by creating a fresh new database, connecting gitea server to it, and “adopting the repositories” found by search. Wiki on repo is intact. I’m still yet to recover my organisation, issues, packages, and organisation repos.
I’m going to use wiki as it creates repo-name-wiki.git and doesn’t use database.
For recovery, specific to my small setup, since it is not going to be very db-intensive, a DR strategy to dump sql and put that into another bare repo with date-time as a branch name should work. Also, as it would be a git, it would serve as an useable point-in-time snapshot to restore from.
I only need the DR as there would be a business partner working on repos, and I can’t afford to be in same sticky situation again.
It can’t be determined in my case what exactly caused this database destruction as not even pg_dirtyread could show any useful rows in issues. The VM was fully isolated and only accessible via just a couple devices, not exposed to public IP, really I fail to understand the missed attack vector. (No, ssh was not password-enabled for the VM in which gitea was running in docker on Alpine linux.).