Created
May 16, 2021 17:47
-
-
Save WeeJeWel/c84e0bcf5c733b125b365cf0e37e8864 to your computer and use it in GitHub Desktop.
Backup all repositories from a GitHub Organization
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 | |
# This script backups all repositories in a GitHub Organization | |
# Required GitHub CLI & Git installed. | |
ORGANIZATION="athombv" | |
echo "Backing up $ORGANIZATION..."; | |
gh repo list $ORGANIZATION --limit 99999 > repos.txt | |
while read line; do | |
IFS=$'\t' | |
lineTabSeparated=($line) | |
repo=$lineTabSeparated; | |
# If directory exists, update it | |
if [ -d "./$repo" ]; then | |
echo "Pulling $repo..." | |
pwd=$(pwd) | |
cd $repo | |
git pull | |
cd $pwd | |
# Clone the new repo | |
else | |
echo "Cloning $repo..." | |
gh repo clone "$repo" "./$repo" | |
fi; | |
done < repos.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment