Created
June 6, 2018 23:53
-
-
Save lrstanley/34ee3b024223af142258ce5d1a7c16c9 to your computer and use it in GitHub Desktop.
GitHub backup script, which utilizes python-github-backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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