~jacksonchen666/gitlab-archive-all-projects

db6c16324dcc916fa05473360b48de955f37edb1 — Jackson Chen 1 year, 11 days ago
init crap
A  => .gitignore +3 -0
@@ 1,3 @@
*.json
*.tar.gz
*.git/

A  => archive_all/archive_projects.sh +10 -0
@@ 1,10 @@
#!/bin/bash
set -ev
# modify below if needed
PERSONAL_ACCESS_TOKEN="$(pbpaste)"
# command line arguments: <project ID>...
# note: curl *should* auto retry on 429. https://github.com/curl/curl/commit/640b9733de74d629af68afcad0ff8bb658e80eff
for i in ${@:1}; do
    echo $i
    curl -v --request POST --retry 250 --header "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/$i/archive" | tee ${i}_archive_response.json
done

A  => download/download_archive/download_project_export.sh +11 -0
@@ 1,11 @@
#!/bin/bash
set -ev
# modify below if needed
PERSONAL_ACCESS_TOKEN="$(pbpaste)"
# command line arguments: <project ID>...
for i in ${@:1}; do
    curl -v --retry 250 --header "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/$i/export" -o ${i}_export_status.download_phase.json
    curl -v --retry 250 --header "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/$i/export/download" -o ${i}_export.tar.gz
    # this is very likely needed...
    #sleep 60
done

A  => download/request/export_project.sh +11 -0
@@ 1,11 @@
#!/bin/bash
set -ev
# modify below if needed
PERSONAL_ACCESS_TOKEN="$(pbpaste)"
# command line arguments: <project ID>...
# note: curl *should* auto retry on 429. https://github.com/curl/curl/commit/640b9733de74d629af68afcad0ff8bb658e80eff
for i in ${@:1}; do
    echo $i
    curl -v --retry 250 --request POST --header "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/$i/export" | tee ${i}_export_response.json
    curl -v --retry 250 --header "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" "https://gitlab.com/api/v4/projects/$i/export" | tee ${i}_export_status.json
done