Last active
May 20, 2022 11:11
-
-
Save cosmtrek/123a40ea650f68cb041de2e58ab95585 to your computer and use it in GitHub Desktop.
backup github repo
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 | |
BACKUP_DIR="$HOME/backup/repo-mirrors" | |
REPOS=( | |
"cosmtrek/dotfiles" | |
"cosmtrek/air" | |
"typefuture/powerbox" | |
"zdharma-continuum/zinit" | |
"neovim/neovim" | |
) | |
mkdir -p $BACKUP_DIR && cd $BACKUP_DIR | |
echo "=== Entering $BACKUP_DIR ..." | |
for r in ${REPOS[@]}; do | |
name="$(echo $r | cut -d'/' -f2)" | |
if [ ! -d "$BACKUP_DIR/${name}.git" ]; then | |
echo "=== Cloning $r ..." && git clone --mirror "git@github.com:${r}.git" | |
fi | |
done | |
for f in $BACKUP_DIR/*; do | |
if [ -d "$f" ]; then | |
( cd $f && echo "=== Updating $f ..." && git remote update --prune && echo "") | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment