Skip to content

Instantly share code, notes, and snippets.

@cosmtrek
Last active May 20, 2022 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmtrek/123a40ea650f68cb041de2e58ab95585 to your computer and use it in GitHub Desktop.
Save cosmtrek/123a40ea650f68cb041de2e58ab95585 to your computer and use it in GitHub Desktop.
backup github repo
#!/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