From ba4b9190ae731096694cbdd747242fd3e79ba913 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Mon, 23 Sep 2019 10:02:54 +0100 Subject: Add script for gitolite backup --- bin/.local/bin/gitolite-backup | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 bin/.local/bin/gitolite-backup (limited to 'bin/.local') 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 -- cgit v1.2.3