Skip to content

Instantly share code, notes, and snippets.

@quonic
Created October 7, 2021 19:47
Show Gist options
  • Save quonic/d2a87d498584d403c6ed63749d13b36a to your computer and use it in GitHub Desktop.
Save quonic/d2a87d498584d403c6ed63749d13b36a to your computer and use it in GitHub Desktop.
Backup/Export GitLab repositories
# This will clone each repo that your user/token has access to.
# I created this to help backup the repo's, then wipe the gitlab server, reinstall, and restore.
$token = "<YourTokenHere>"
$Url = "https://<YourDomainHere>/api/v4/projects/?per_page=500"
$Projects = Invoke-RestMethod -Headers @{ 'PRIVATE-TOKEN' = $token } -Method Get -Uri $Url
$Projects.http_url_to_repo | ForEach-Object {
git.exe clone $_
}
@quonic
Copy link
Author

quonic commented Oct 7, 2021

This is for a free self hosted version.
This will get rate limited with a 429 HTTP error. Just rerun it a few more times until you get fatal: destination path 'MyRepo' already exists and is not an empty directory. for each repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment