Restore repository / orphan repository

The server that was running my local GitLab CE (virtual machine) was hit by a ransomware attack, all the vm files were encrypted. When I setup GitLab CE, I setup the storage for builds, git-data, shared, and upload to point to a external storage.

Those folders and files in the still exists and were not corrupted by the ransomware.

I have rebuilt the GitLab CE server, and modified the gitlab.rb to point to the external storage i was using with the old GitLab CE server.

How do I get all the repositories back into the new GitLab CE server ?

You would need to restore using one of the backups from /var/opt/gitlab/backups

If you don’t have one of these backups, I believe there are posts on this forum on how to mass import the repositories - I do remember seeing something like that during the last year at least on this forum.

All the files for the VM are encrypted. so I cant start the VM and get to /var/opt/gitlab/backups. I was doing some backups, I do have the gitlab.rb as well as the gitlabs-secret.json files. And as I said the git-data folder was redirected to external storage.

So I have the repositories, but dont know how to get them back into the new Gitlab server.

I am posting this fix, which help me recover my repositories in the hopes that it will help someone else in the future.

Background :
Running GitLab CE on Ubuntu 20.04 on a VM.
GitLab CE configured to use external storage for repositories
Ransomware attach which encrypted all the VM files.

Pre Recovery
Rebuild new VM using Ubuntu 20.04
Install GitLab CE.
Configured GitLab CE to point to same external storage location
No repositories show up in the Web GUI
copied external storage repository to local using the following command:
sudo -u git sh -c ‘tar -C //gitlab-nfs/git-data/repositories -cf - – . | tar -C /mnt/gitlab/repositories -xvf -’
Attempted to import repository with the following command :
sudo gitlab-rake gitlab:import:repos["/mnt/gitlab/repositories"]
Still no repositories showing up in the Web GUI, also getting errors that the repositories already exists.
Change GitLab CE configuration to use default locations for repository storage.
Attempted to import repository again with the following command :
sudo gitlab-rake gitlab:import:repos["/mnt/gitlab/repositories"]
In the Web GUI I see the repositories, but look to be empty.
Run import again with the following command (importing from external storage location)
sudo gitlab-rake gitlab:import:repos["/gitlab-nfs/git-data/repositories"]
In the Web GUI, I see one repository that has data.
Log out as root of Web GUI
Log into Web GUI as the owner of the repositories.
All repositories are recovered, and all files are in each repository.
Downloaded each repository as backup.

Site that helped me :