Skip to content

Instantly share code, notes, and snippets.

@lrstanley
Created June 6, 2018 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrstanley/34ee3b024223af142258ce5d1a7c16c9 to your computer and use it in GitHub Desktop.
Save lrstanley/34ee3b024223af142258ce5d1a7c16c9 to your computer and use it in GitHub Desktop.
GitHub backup script, which utilizes python-github-backup
#!/bin/bash
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
fi
_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