Allow use of rsync when fetching logs

Change-Id: I561ae3c9ebe7765d76a0835c712d17e86b731df3
(cherry picked from commit 359f4d84608c44541c43bfc564893ac76c326063)
diff --git a/tools/test/bin/atomix-fetch-logs b/tools/test/bin/atomix-fetch-logs
index 0860193..53129bc 100755
--- a/tools/test/bin/atomix-fetch-logs
+++ b/tools/test/bin/atomix-fetch-logs
@@ -38,6 +38,22 @@
 # Execute the remote commands
 for node in $nodes; do
     echo "fetching from ${node}..."
+    USE_RSYNC=${USE_RSYNC:-'false'}
+    # Check if RSYNC is installed
+    if [ "$USE_RSYNC" = "true" ]; then
+      if ssh $ONOS_USER@${node} $SSH_OPTIONS which rsync >&2 > /dev/null; then
+        echo "Using rsync"
+      else
+        echo "Installing rsync"
+        # TODO check remote OS and use proper method to install rsync
+        ssh $ONOS_USER@${node} sudo apt-get install -y rsync || USE_RSYNC='false'
+      fi
+    fi
+
     mkdir -p ${node}
-    scp -p $ONOS_USER@[${node}]:$ATOMIX_INSTALL_DIR/log/atomix.log* ./${node}/
+    if [ "$USE_RSYNC" = "true" ]; then
+        rsync -avhz --progress [$ONOS_USER@${node}]:$ATOMIX_INSTALL_DIR/log/atomix.log* ./${node}/
+    else
+        scp -p $ONOS_USER@[${node}]:$ATOMIX_INSTALL_DIR/log/atomix.log* ./${node}/
+    fi
 done