deevroman
deevroman

Reputation: 145

How to clone all public repositories from gitlab server?

There is an unstable gitlab server and I am not sure that it will be able to work in the future. Therefore, I want to make a backup copy of all the repositories (projects) that are there.

Cloning the source code will be enough, but it will be great if there is a way to save issues as well. Are there any ways to do this?

Upvotes: 2

Views: 454

Answers (1)

Arty-chan
Arty-chan

Reputation: 3026

It depends on what kind of access you have, but if you don't have administrator access to do a full backup, then the best thing to do is to use a couple of API endpoints to get the information you need and go from there.

  1. Use the Projects API to get a list of all projects accessible to you.
    • Note the pagination limits.
    • What you store depends on how you want to get the information.
    • Store at least the ID number of each.
    • Filter by membership if you only want the ones you're a member of.
    • Filter by min_access_level = maintainer (or higher) if you want to export whole projects.
  2. Use the Project export API to trigger a project export for each project you're a member of, and you're a maintainer (or higher).
  3. For all other projects where you have a lower role, or where it's public, you could still use git clone for the repositories by storing the ssh_url_to_repo or http_url_to_repo from the Projects API and running through each.
    • For all other parts of a project, you could store the JSON version to recreate them later if you want to go through the hassle. For example, for issues, use the Issues API.

Upvotes: 1

Related Questions