diff options
author | Malf Furious <m@lfurio.us> | 2017-04-30 17:30:03 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2017-04-30 17:30:03 -0400 |
commit | 61da049cebae2d30ec691f03e43a0cd33aa04915 (patch) | |
tree | 8b9ec0625ce855473164dd29fc7e2f2f2870e02d /rsync.sh | |
parent | 9900821d6b8c704bb8f8399d1a343aa5d780abf7 (diff) | |
download | systrunk-61da049cebae2d30ec691f03e43a0cd33aa04915.tar.gz systrunk-61da049cebae2d30ec691f03e43a0cd33aa04915.zip |
Add rsync module
Diffstat (limited to 'rsync.sh')
-rw-r--r-- | rsync.sh | 42 |
1 files changed, 42 insertions, 0 deletions
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 <src> <dst> [<link>] +# +# Perform normal rsync operations to transfer files to or from the +# repository. If <link> 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 +} |