Github Backups

Author
Discussion

silentbrown

Original Poster:

9,225 posts

122 months

Monday 5th June 2023
quotequote all
Any recommendations for a service/app that handles this easily? ~30 repos.

Backup could be download to local system or to cloud storage.


wheelerc

225 posts

148 months

Monday 5th June 2023
quotequote all
Just the git repositories? Cron job with 'git pull' in it?

Or do you want all the related issues/wikis etc backed up?

silentbrown

Original Poster:

9,225 posts

122 months

Monday 5th June 2023
quotequote all
wheelerc said:
Just the git repositories? Cron job with 'git pull' in it?

Or do you want all the related issues/wikis etc backed up?
That could work. Needs to be kept up to date with list of repos and error reporting will be a bit crude, though.

ribpx

559 posts

154 months

Monday 19th June 2023
quotequote all
Quite like the idea of a simple shell script / cron job.

You could use the API to get a list of repositories, then just pipe that into a sequential git clone.

ChatGPT suggested this (not tested).



#!/bin/bash

# Your GitHub username and personal access token
GITHUB_USERNAME="your_username"
GITHUB_TOKEN="your_personal_access_token"

# Output directory where repositories will be cloned
OUTPUT_DIR="path_to_output_directory"

# GitHub API endpoint to fetch repository list
API_URL="https://api.github.com/user/repos"

# Send API request to retrieve repository list
REPOS=$(curl -s -u "$GITHUB_USERNAME:$GITHUB_TOKEN" "$API_URL")

# Clone each repository
for repo in $(echo "$REPOS" | jq -r '.[].ssh_url'); do
git clone "$repo" "$OUTPUT_DIR/$(basename "$repo" .git)"
done