Skip to content

Instantly share code, notes, and snippets.

@robatwilliams
Last active April 12, 2020 16:55
Show Gist options
  • Save robatwilliams/ea326929efeeae0f914869402a4874b0 to your computer and use it in GitHub Desktop.
Save robatwilliams/ea326929efeeae0f914869402a4874b0 to your computer and use it in GitHub Desktop.
Backup GitHub repositories as Git bundles
#!/usr/bin/env bash
declare -a repositories=(
'awesome-webhid'
'config'
'correct'
'decent-code'
'diff-hero'
'differential-loading-poc'
'enforce-frontend-architecture'
'eslint-config-robatwilliams'
'es-compat'
'git-ticket-number-prefix-hook'
'hills-api'
'knockout-handybits'
'mmex2json'
'react-starter'
'redux-saga-vs-tale'
'web-server-config-test'
'webhid-demos'
'will-it-cache'
'workie'
)
echo "${#repositories[@]} repositories"
for repository in ${repositories[@]}
do
echo "$repository..."
if [ -d $repository ]; then
cd $repository
git pull
else
git clone "https://github.com/robatwilliams/$repository.git"
cd $repository
fi
declare file_name="../$repository-$(git rev-parse --short HEAD).bundle"
if [ -f $file_name ]; then
echo 'Found bundle is current'
else
git bundle create $file_name --all
fi
cd -
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment