Skip to content

Instantly share code, notes, and snippets.

@brianv0
Created September 12, 2015 00:45
Show Gist options
  • Save brianv0/22dbfb1af5c2995d6bb4 to your computer and use it in GitHub Desktop.
Save brianv0/22dbfb1af5c2995d6bb4 to your computer and use it in GitHub Desktop.
Git repository backup and bundler
#!/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