Skip to content

Instantly share code, notes, and snippets.

@ohhdemgirls
Created May 2, 2019 12:37
Show Gist options
  • Save ohhdemgirls/d22598a6a8d18aa3a0b85aa5b5cdb62f to your computer and use it in GitHub Desktop.
Save ohhdemgirls/d22598a6a8d18aa3a0b85aa5b5cdb62f to your computer and use it in GitHub Desktop.
#!/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