From 61da049cebae2d30ec691f03e43a0cd33aa04915 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 30 Apr 2017 17:30:03 -0400 Subject: Add rsync module --- rsync.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 rsync.sh (limited to 'rsync.sh') diff --git a/rsync.sh b/rsync.sh new file mode 100644 index 0000000..a77d681 --- /dev/null +++ b/rsync.sh @@ -0,0 +1,42 @@ +## +# systr_rsync_normal [] +# +# Perform normal rsync operations to transfer files to or from the +# repository. If is set, it is used as the --link-dest value +# for rsync. This function is polymorphic for both local and remote +# repositories. +## +function systr_rsync_normal +{ + if [ $# -lt 2 ]; then + echo "Fatal: too few arguments to systr_rsync_normal" + exit 1 + fi + + src="$1" + dst="$2" + + if [ $# -gt 2 ]; then + link="--link-dest=\"$3\"" + else + link="" + fi + + if [[ "$remote" == "" ]]; then + rsync -az --info=progress2 --info=stats2 \ + --delete --exclude='*.systr' \ + $link \ + "$src" "$dst" + else + if [[ "$src" == "." ]]; then + dst="$remote:$dst" + else + src="$remote:$src" + fi + + rsync -az -e ssh --info=progress2 --info=stats2 \ + --delete --exclude='*.systr' \ + $link \ + "$src" "$dst" + fi +} -- cgit v1.2.3