UP  |  HOME

github-backup

Makes a copy of my public repositories and any starred repositories. Toss a script to run it in cron.weekly or cron.monthly.

I found it has been broken for a while. Probably since github disabled git: protocol sometime in 2022. Anyway despite the changelog and a terrible attempt at modifying the code I couldn't get it to clone from https: like I wanted. My workaround was to configure the user's git so that it rewrites URLs. I documented it in the config below for reference.

Listing 1: /etc/cron.monthly/github-backup
#!/bin/bash
mkdir -p /var/backups/github-username
cd /var/backups/github-username && github-backup username

# Even though github-backup has a changelog from 2016 that says it
# defaults to https I can't get it to do that. Even removing git:
# from the URL Enum seemed to have no effect. Always when trying to 
# fetch a new repo it would use git: protocol.

# My workaround was to rewrite urls with a git config.
# I used advice from https://stackoverflow.com/questions/1722807/how-to-convert-git-urls-to-http-urls
# So now on the account that runs this script I have in ~/.gitconfig
#    [url "https://github.com/"]
#            insteadOf = git://github.com/