简体   繁体   中英

Recovering GitLab repos from the server-side directories

I had GitLab-CE running on an Ubuntu 16 VPS, but due to some nginx issues and just problems more generally, I ended up unable to log into GitLab on my server. Since I had to wipe the server anyway, I figured I'd just back up the /var/opt/gitlab/git-data/repositories/ folder and hope for the best as far as recovering those with a new GitLab install later.

It's later. I now have GitLab-EE installed, the Omnibus version, on Ubuntu 18.04. I moved the folders from /var/opt/gitlab/git-data/repositories/username/ from the backup to the new install. These are folders, named reponame.git and reponame.wiki.git for each one. I've got file permissions set correctly as well.

The only things that are clearly different is:

  1. the user git belongs to the group git on the new repo made on the new server, but the old ones have group root with user git

  2. When doing ls -al , the newly-created repo has the following for hooks

hooks -> /opt/gitlab/embedded/service/gitlab-shell/hooks/

while the old has hooks.old.1528595819/ which only had a readme file about hooks, but nothing helpful.

What are my chances of recovering these in the new GitLab installation? I can't just make hooks be a symlink to /opt/gitlab/.../hooks/ for all of these and change the group of the owner, since that's not doing anything to get these to show up on the web interface.

What is my best option here?

I've worked out a solution which is more time consuming than I'd like but it definitely got me all my files back. Here's what I did, in case it's helpful for someone else down the road. Lots of times stuff gets abandoned without answers, and if you're just trying to get your files back, this might do it for you.

  1. Copied the folders (named [repo name].git) to a folder on a computer that isn't the server. Put each in its own containing folder. So for example sample.git gets put in a folder called sample .
  2. Go to that directory in the terminal
  3. Re-initialise the repo with git init
  4. Restore the files locally with git reset --hard HEAD
  5. Set the remote server as a new branch for that repo and commit. Now the files are showing up on the remote GitLab server as accessible.

The git init step was just a guess, but it's exactly what was needed.

I'd still love to hear if there's a quicker way to batch-renew repos all on the server, but in lieu of that, this works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM