Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
GitHub backup script, which utilizes python-github-backup
USER="${1:?usage: $0 <user> <archive>}"
ARCHIVE_LOC="${2:?usage: $0 <user> <archive>}"
which github-backup > /dev/null 2>&1 || pip install github-backup
if [ -z "$GH_BACKUP_TOKEN" ];then
echo 'missing $GH_BACKUP_TOKEN...'
exit 1
_tmp=$(mktemp -d -p "/run/user/$(id -u)" -t "github-backup-XXXXX")
if [ "$?" != 0 ];then exit 1;fi
trap "rm -rf $_tmp" EXIT
echo "using '$_tmp'..."
github-backup \
--token "$GH_BACKUP_TOKEN" \
--starred \
--followers \
--following \
--issues \
--issue-comments \
--repositories \
--wikis \
--gists \
--starred-gists \
--private \
--output-directory "$_tmp" "$USER"
tar -czvf "$ARCHIVE_LOC" -C "$_tmp" .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment