Created
September 12, 2015 00:45
-
-
Save brianv0/22dbfb1af5c2995d6bb4 to your computer and use it in GitHub Desktop.
Git repository backup and bundler
This file contains hidden or 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 | |
repolist="$1" | |
while IFS='' read -r repo || [[ -n "$repo" ]]; do | |
local_dir=$(basename "$repo") | |
if [ -e "$local_dir" ]; then | |
echo "Repo exists, updating $local_dir..." | |
git --git-dir $local_dir remote update | |
else | |
echo "Cloning $repo..." | |
git clone --mirror "$repo" | |
fi | |
echo "Bundling repository..." | |
date=$(date "+%Y-%m-%d") | |
local_bak=$local_dir"-"$date".bundle" | |
echo $local_bak | |
git --git-dir $local_dir bundle create $local_bak --all | |
done < "$repolist" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment