TLDR: My GitLab server (gitlab-ce, 15.6.2, Ubuntu) is dead and our only backup is corrupted, but I do have all the local files that made up the server. Is there any way I can use these to restore my repos, pipelines, users, etc on another GitLab instance? Or, alternatively, am I screwed?
To clarify I have everything from the .git directory, including
- Repositories folder (Hashed)
- LFS Store
What Have I tried?
- Naively I have tried copying and pasting the relevant GitLab directories into a new server, but that hasn’t worked as expected.
- Unhashing the repos, but I couldn’t find much info and ran into a dead end
- Recovering the backup without success, it’s just an invalid TAR file from a backup that failed partway through.
Currently I haven’t been able to find any resources that describe this situation, I’d really appreciate if anyone had some insight.
You could try:
- Install gitlab-ce 15.6.2 on new server (has to be same version as existing install).
- Copy /opt/gitlab, /var/opt/gitlab, /var/log/gitlab, /etc/gitlab to the new server, overwriting what you just installed in point 1. Make sure if you copy to ensure permissions are also copied - rsync would be good using the -a flag.
- Once gitlab.rb and gitlab-secrets.json are in /etc/gitlab, you can then try
Not sure if that would be possible, but it’s worth trying anyway just in case.
Tried this but the past repos and other bits weren’t showing up in the new instance. I could create a new repo and it would show up in the “@hashed” directory next to all the ones I want to restore, but only the new ones were recognized it seems…
I did find a fix that works well enough though! I misconstrued that “hashed” repos meant that the project files themselves were put through a hash and unrecoverable without a key. In reality hashing is the technique used to organize the projects in the repos directory. So really, all the bare repos were just hidden behind several scarily named folders.
For anyone trying to recover repos from local git files, you can:
- go to /repositories/@hashed
- cd into “<hash num>/<longer hash num>/<huge hash.git>”. This is a bare git repository that was on your server
- git remote add origin “<new remote project url>”
- git push --all origin
And that repo should be up on that new project. It isn’t ideal because I’ve lost everything else related to the server but at least my repos are safe.