diff options
author | Urbain Vaes <urbain@vaes.uk> | 2019-09-23 10:02:54 +0100 |
---|---|---|
committer | Urbain Vaes <urbain@vaes.uk> | 2019-09-23 10:02:54 +0100 |
commit | ba4b9190ae731096694cbdd747242fd3e79ba913 (patch) | |
tree | 8a2c5339461af0ef5134e8aeba7779000b83b54f | |
parent | 7d1499cda323663e25ff2c0bd87944e7276009ae (diff) |
Add script for gitolite backup
-rwxr-xr-x | bin/.local/bin/gitolite-backup | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/.local/bin/gitolite-backup b/bin/.local/bin/gitolite-backup new file mode 100755 index 0000000..8d99b75 --- /dev/null +++ b/bin/.local/bin/gitolite-backup @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +server="urbain@vaes.uk" +dir_backup="$HOME/Documents/gitolite_$server" +ssh urbain@vaes.uk 'find /var/lib/gitolite/repositories -type d -name "*.git"' | \ + sed "s#/var/lib/gitolite/repositories/##" | sed "s/\.git$//" | \ + while read -r repo + do + if [[ ! -d "$dir_backup/$repo" ]] + then + dir_clone="$(dirname "$dir_backup/$repo")" + mkdir -p "$dir_clone" + cd "$dir_clone" || exit + echo "Cloning $repo in $(pwd)" + git clone "gitolite@vaes.uk:$repo" + else + dir_pull="$dir_backup/$repo" + cd "$dir_pull" || exit + echo "Pulling in $(pwd)" + git pull origin master + fi + done |