Importing bare repositories from Gitolite: gitlabe rake does not work

Trying to import repositories from Gitolite.
Following this guide:

sudo -u git mkdir -p /var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d")/packages

Then I cloned the repositories as the user git.
git clone --mirror

sudo chown -R git:git /var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d")
sudo gitlab-rake gitlab:import:repos['/var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d")']

There was no output from this. None of the repositories where imported.

Running GitLab EE 13.9.1 (no license yet).

The folder name must end with .git suffix so it should look like /var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d")/packages/project.git. You can instruct git clone to clone to specific folder git clone --mirror /var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d")/packages/project.git or rename them manually.

All repositories I cloned are ended with .git.
I used the git clone --mirror when I cloned the repositories from Gitolote.

Have you added the config about project path like

  fullpath = gitlab-org/gitlab

to each project’s Git configuration file after cloning?

I added this to each repository config

  fullpath = gitlab-org/gitlab

However still nothing happens when I try to import with the rake command.
The repositories I am attempting to import are not originating from GitLab, but from an Gitolite instance.

Have I misunderstood this documentation?
Is it only for importing from one previous GitLab instance?

I want everything in the mirrored repository to be imported into GitLab.
Simply cloning, and pushing the repository to GitLab is not enough as it would leave out much from the repository.

@sverre Would the GUI method be easier? Under New Project there is an option for Import Project, whilst there isn’t a specific option for Gitolite maybe the Repo by URL would work? I know obviously then it would only allow you to import a project one at a time. I expect the reason why you are doing via console is to get all repos in one go.

I do know from experience, that if I want to mirror a repository, on free version of Gitlab it’s only possible to mirror by pushing from Gitlab, to another place. So for example, on my install local, I can push to to make sure I have a mirrored copy of my work, which will continually sync when I push changes, but the pull option is only available with a paid version of Gitlab. Hence why I push rather than pull.

Perhaps the reason why your pull/mirror method isn’t working if it’s not a paid version yet - irrespective if attempting to mirror from the GUI or console. The import project would work however, but if you are attempting to mirror changes from Gitolite to Gitlab, I expect you will need a paid version. If you were wanting to mirror from Gitlab to Gitolite, then with push mirror type being available in the free version, that would most likely work like my version which pushes from my private gitlab to the public one.

Link to the mirror info: Repository mirroring | GitLab

pull mirror only in Premium and higher.

1 Like

A GUI would be easier for just a few repositories, but not for 400+.

It strikes me that this gitlab-rake importing is only for GitLab repositories.

Perhaps it is because we does not yet have a license. Should not GitLab EE without a license work just like GitLab CE. Then it become a question if GitLab CE supports bulk importing from mirrored repositories.

We do not want to mirror, but I use git clone --mirror in order to get the complete repository with everything it has of commits, branches, tags, notes, hooks, and other various configuration.

I know it is possible, we have migrated our repositories like that. And now I have figured out what’s wrong.
This command from the documentation page is wrong sudo gitlab-rake gitlab:import:repos['/var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d")']
The /var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d") is in single quotes so $(date "+%Y-%m-%d") does not get expanded by bash.
Actually using real folder path gitlab-rake gitlab:import:repos['/var/opt/gitlab/git-data/repository-import-2021-03-04'] worked and repository was imported.

The fullpath = some/path in GIT config was ignored anyway and it got imported according to directory tree.

1 Like

Can I, Should I, delete the repositories I cloned for the migration?
After the import, the repositories have been replaced with a project.git.bundle file, and it takes up space.
sudo rm -Rf /var/opt/gitlab/git-data/repository-import-$(date "+%Y-%m-%d")

I think its safe to delete them. I deleted them and imported repos seems fine.

i wrote this script for migrating from gitolite to gitlab… maybe it will help you parrotKDEi3/ at master · alembiq/parrotKDEi3 · GitHub

1 Like