summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2017-10-14 18:53:46 +0200
committerPaul Kocialkowski <contact@paulk.fr>2017-10-14 18:53:46 +0200
commit115aa33b40f69f7258748fba99ab57782da3794e (patch)
treed8531abfad68e10c7f1897241515d32c31334479
parente38024893992966283e8397af1aa6dfc65241d73 (diff)
downloadsync-115aa33b40f69f7258748fba99ab57782da3794e.tar.gz
sync-115aa33b40f69f7258748fba99ab57782da3794e.tar.bz2
sync-115aa33b40f69f7258748fba99ab57782da3794e.zip
Add support for rsync dry run
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rwxr-xr-xsync12
1 files changed, 10 insertions, 2 deletions
diff --git a/sync b/sync
index d98e596..1d54ea9 100755
--- a/sync
+++ b/sync
@@ -168,6 +168,8 @@ sync() {
local descriptor
local name
local match
+ local dry
+ local dry_description
set -e
@@ -197,6 +199,12 @@ sync() {
continue
fi
+ if [ -n "$DRY" ]
+ then
+ dry="--dry-run"
+ dry_description=" \e[1;31m(dry run)\e[0m"
+ fi
+
source_path=$( host_file_path "$descriptor" )
destination_path=$( host_file_path "$match" )
@@ -204,9 +212,9 @@ sync() {
host_excludes "$destination_name" "$name" >> "$DOTEXCLUDES"
host_excludes "$source_name" "$name" >> "$DOTEXCLUDES"
- echo -e "Sync \e[1;34m$name\e[0m from \e[1;33m$source\e[0m to \e[1;33m$destination\e[0m"
+ echo -e "Sync \e[1;34m$name\e[0m from \e[1;33m$source\e[0m to \e[1;33m$destination\e[0m$dry_description"
- $RSYNC --exclude-from="$DOTEXCLUDES" "$source_prefix$source_path" "$destination_prefix$destination_path"
+ $RSYNC $dry --exclude-from="$DOTEXCLUDES" "$source_prefix$source_path" "$destination_prefix$destination_path"
rm "$DOTEXCLUDES"
done