Created
May 2, 2019 12:37
-
-
Save ohhdemgirls/d22598a6a8d18aa3a0b85aa5b5cdb62f to your computer and use it in GitHub Desktop.
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/sh | |
set -x | |
USER="$1" | |
API_URL="https://api.github.com/users/${USER}/repos?type=owner" | |
DATE=$(date +"%Y%m%d") | |
TEMP_DIR="github_${USER}_${DATE}" | |
BACKUP_FILE="${TEMP_DIR}.tgz" | |
mkdir "$TEMP_DIR" && cd "$TEMP_DIR" | |
curl -s "$API_URL" | grep -Eo '"git_url": "[^"]+"' | awk '{print $2}' | xargs -n 1 git clone | |
cd - | |
tar zcf "$BACKUP_FILE" "$TEMP_DIR" && ./rclone --config r.conf -vvv copy "github_${USER}_${DATE}.tgz" gitbackup:/GitHub/Users/ | |
rm -rf "$TEMP_DIR" | |
rm "github_${USER}_${DATE}.tgz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment