I host all my code in GitHub now that it is free for private as well as public repositories. Before that I used GitLab, which I may return if I implement CI/CD on my own personal projects.
One of the concerns I have is what happens if GitHub is unavailable? I would like a complete daily copy of my GitHub repositories available on-demand.
Luckily there is a great python package available that does just this. Once installed, adding a shell variable GIT_TOKEN, using a simple bash script and crontab you can have full daily Git backups. Just replace username in the script. If you’re in an organization you’ll have to add –organization, also.
#!/bin/bash
_GIT_USER="username"
_NOW=$(date +"%Y-%m-%d")
github-backup $_GIT_USER --token $GIT_TOKEN --output-directory /tmp/gitbackup --repositories --private
cd /tmp
tar -jcf github-backup-$_NOW.tbz2 tobyslab/
mv github-backup-$_NOW.tbz2 ~/github-backups