Blame SOURCES/rear-bz1930662.patch

f88787
diff --git a/usr/share/rear/backup/NETFS/default/500_make_backup.sh b/usr/share/rear/backup/NETFS/default/500_make_backup.sh
f88787
index 02c204c5..60c80b5f 100644
f88787
--- a/usr/share/rear/backup/NETFS/default/500_make_backup.sh
f88787
+++ b/usr/share/rear/backup/NETFS/default/500_make_backup.sh
f88787
@@ -16,6 +16,8 @@ function set_tar_features () {
f88787
     FEATURE_TAR_IS_SET=1
f88787
 }
f88787
 
f88787
+local backup_prog_rc
f88787
+
f88787
 local scheme=$( url_scheme $BACKUP_URL )
f88787
 local path=$( url_path $BACKUP_URL )
f88787
 local opath=$( backup_path $scheme $path )
f88787
diff --git a/usr/share/rear/backup/RSYNC/GNU/Linux/610_start_selinux.sh b/usr/share/rear/backup/RSYNC/GNU/Linux/610_start_selinux.sh
f88787
index c560ec94..1692ba4c 100644
f88787
--- a/usr/share/rear/backup/RSYNC/GNU/Linux/610_start_selinux.sh
f88787
+++ b/usr/share/rear/backup/RSYNC/GNU/Linux/610_start_selinux.sh
f88787
@@ -1,5 +1,7 @@
f88787
 # Start SELinux if it was stopped - check presence of  $TMP_DIR/selinux.mode
f88787
 
f88787
+local backup_prog_rc
f88787
+
f88787
 [ -f $TMP_DIR/selinux.mode ] && {
f88787
 	touch "${TMP_DIR}/selinux.autorelabel"
f88787
 	cat $TMP_DIR/selinux.mode > $SELINUX_ENFORCE
f88787
@@ -13,19 +15,19 @@
f88787
 		ssh $RSYNC_USER@$RSYNC_HOST "chmod $v 755 ${RSYNC_PATH}/${RSYNC_PREFIX}/backup" 2>/dev/null
f88787
 		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" \
f88787
 		 "$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel" 2>/dev/null
f88787
-		_rc=$?
f88787
-		if [ $_rc -ne 0 ]; then
f88787
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$_rc]}]"
f88787
+		backup_prog_rc=$?
f88787
+		if [ $backup_prog_rc -ne 0 ]; then
f88787
+			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
f88787
 			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
f88787
 		fi
f88787
 		;;
f88787
 
f88787
 	(rsync)
f88787
-		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" ${BACKUP_RSYNC_OPTIONS[@]} \
f88787
+		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" "${BACKUP_RSYNC_OPTIONS[@]}" \
f88787
 		 "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel"
f88787
-		_rc=$?
f88787
-		if [ $_rc -ne 0 ]; then
f88787
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$_rc]}]"
f88787
+		backup_prog_rc=$?
f88787
+		if [ $backup_prog_rc -ne 0 ]; then
f88787
+			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
f88787
 			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
f88787
 		fi
f88787
 		;;
f88787
diff --git a/usr/share/rear/backup/RSYNC/GNU/Linux/620_force_autorelabel.sh b/usr/share/rear/backup/RSYNC/GNU/Linux/620_force_autorelabel.sh
f88787
index cae12e38..9a17d6bb 100644
f88787
--- a/usr/share/rear/backup/RSYNC/GNU/Linux/620_force_autorelabel.sh
f88787
+++ b/usr/share/rear/backup/RSYNC/GNU/Linux/620_force_autorelabel.sh
f88787
@@ -1,3 +1,5 @@
f88787
+local backup_prog_rc
f88787
+
f88787
 [ -f $TMP_DIR/force.autorelabel ] && {
f88787
 
f88787
 	> "${TMP_DIR}/selinux.autorelabel"
f88787
@@ -11,19 +13,19 @@
f88787
 		ssh $RSYNC_USER@$RSYNC_HOST "chmod $v 755 ${RSYNC_PATH}/${RSYNC_PREFIX}/backup" 2>/dev/null
f88787
 		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" \
f88787
 		 "$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel" 2>/dev/null
f88787
-		_rc=$?
f88787
-		if [ $_rc -ne 0 ]; then
f88787
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$_rc]}]"
f88787
+		backup_prog_rc=$?
f88787
+		if [ $backup_prog_rc -ne 0 ]; then
f88787
+			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
f88787
 			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
f88787
 		fi
f88787
 		;;
f88787
 
f88787
 	(rsync)
f88787
-		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" ${BACKUP_RSYNC_OPTIONS[@]} \
f88787
+		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" "${BACKUP_RSYNC_OPTIONS[@]}" \
f88787
 		 "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel"
f88787
-		_rc=$?
f88787
-		if [ $_rc -ne 0 ]; then
f88787
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$_rc]}]"
f88787
+		backup_prog_rc=$?
f88787
+		if [ $backup_prog_rc -ne 0 ]; then
f88787
+			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
f88787
 			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
f88787
 		fi
f88787
 		;;
f88787
@@ -35,8 +37,7 @@
f88787
 		# probably using the BACKUP=NETFS workflow instead
f88787
 		if [ -d "${opath}" ]; then
f88787
 			if [ ! -f "${opath}/selinux.autorelabel" ]; then
f88787
-				> "${opath}/selinux.autorelabel"
f88787
-				StopIfError "Failed to create selinux.autorelabel on ${opath}"
f88787
+				> "${opath}/selinux.autorelabel" || Error "Failed to create selinux.autorelabel on ${opath}"
f88787
 			fi
f88787
 		fi
f88787
 		;;
f88787
diff --git a/usr/share/rear/backup/RSYNC/default/200_check_rsync_relative_option.sh b/usr/share/rear/backup/RSYNC/default/200_check_rsync_relative_option.sh
f88787
index 60330007..cedee9ce 100644
f88787
--- a/usr/share/rear/backup/RSYNC/default/200_check_rsync_relative_option.sh
f88787
+++ b/usr/share/rear/backup/RSYNC/default/200_check_rsync_relative_option.sh
f88787
@@ -4,7 +4,7 @@
f88787
 # check for the --relative option in BACKUP_RSYNC_OPTIONS array
f88787
 # for the default values see the standard definition in conf/default.conf file
f88787
 
f88787
-if ! grep -q relative <<< $(echo ${BACKUP_RSYNC_OPTIONS[@]}); then
f88787
+if ! grep -q relative <<< "${BACKUP_RSYNC_OPTIONS[*]}" ; then
f88787
     BACKUP_RSYNC_OPTIONS+=( --relative )
f88787
     Log "Added option '--relative' to the BACKUP_RSYNC_OPTIONS array during $WORKFLOW workflow"
f88787
 fi
f88787
diff --git a/usr/share/rear/backup/RSYNC/default/500_make_rsync_backup.sh b/usr/share/rear/backup/RSYNC/default/500_make_rsync_backup.sh
f88787
index 0d67d362..750a04ca 100644
f88787
--- a/usr/share/rear/backup/RSYNC/default/500_make_rsync_backup.sh
f88787
+++ b/usr/share/rear/backup/RSYNC/default/500_make_rsync_backup.sh
f88787
@@ -2,6 +2,9 @@
f88787
 # This file is part of Relax-and-Recover, licensed under the GNU General
f88787
 # Public License. Refer to the included COPYING for full text of license.
f88787
 
f88787
+local backup_prog_rc
f88787
+local backup_log_message
f88787
+
f88787
 Log "Include list:"
f88787
 while read -r ; do
f88787
 	Log "  $REPLY"
f88787
@@ -11,9 +14,9 @@ while read -r ; do
f88787
 	Log " $REPLY"
f88787
 done < $TMP_DIR/backup-exclude.txt
f88787
 
f88787
-LogPrint "Creating $BACKUP_PROG archive on '${RSYNC_HOST}:${RSYNC_PATH}'"
f88787
+LogPrint "Creating $BACKUP_PROG backup on '${RSYNC_HOST}:${RSYNC_PATH}'"
f88787
 
f88787
-ProgressStart "Running archive operation"
f88787
+ProgressStart "Running backup operation"
f88787
 (
f88787
 	case "$(basename $BACKUP_PROG)" in
f88787
 
f88787
@@ -37,7 +40,7 @@ ProgressStart "Running archive operation"
f88787
 			;;
f88787
 
f88787
 		(*)
f88787
-			# no other backup programs foreseen then rsync so far
f88787
+			# no other backup programs foreseen than rsync so far
f88787
 			:
f88787
 			;;
f88787
 
f88787
@@ -96,7 +99,7 @@ case "$(basename $BACKUP_PROG)" in
f88787
 			;;
f88787
 			esac
f88787
 
f88787
-			ProgressInfo "Archived $((size/1024/1024)) MiB [avg $((size/1024/(SECONDS-starttime))) KiB/sec]"
f88787
+			ProgressInfo "Backed up $((size/1024/1024)) MiB [avg $((size/1024/(SECONDS-starttime))) KiB/sec]"
f88787
 		done
f88787
 		;;
f88787
 
f88787
@@ -113,24 +116,23 @@ ProgressStop
f88787
 wait $BackupPID
f88787
 
f88787
 transfertime="$((SECONDS-starttime))"
f88787
-_rc="$(cat $TMP_DIR/retval)"
f88787
+backup_prog_rc="$(cat $TMP_DIR/retval)"
f88787
 
f88787
 sleep 1
f88787
 # everyone should see this warning, even if not verbose
f88787
-test "$_rc" -gt 0 && VERBOSE=1 LogPrint "WARNING !
f88787
-There was an error (${rsync_err_msg[$_rc]}) during archive creation.
f88787
-Please check the archive and see '$RUNTIME_LOGFILE' for more information.
f88787
+test "$backup_prog_rc" -gt 0 && Error "
f88787
+There was an error (${rsync_err_msg[$backup_prog_rc]}) during backup creation.
f88787
+Please check the destination and see '$RUNTIME_LOGFILE' for more information.
f88787
 
f88787
-Since errors are often related to files that cannot be saved by
f88787
-$BACKUP_PROG, we will continue the $WORKFLOW process. However, you MUST
f88787
-verify the backup yourself before trusting it !
f88787
+If the error is related to files that cannot and should not be saved by
f88787
+$BACKUP_PROG, they should be excluded from the backup.
f88787
 
f88787
 "
f88787
 
f88787
-_message="$(tail -14 ${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log)"
f88787
-if [ $_rc -eq 0 -a "$_message" ] ; then
f88787
-	LogPrint "$_message in $transfertime seconds."
f88787
+backup_log_message="$(tail -14 ${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log)"
f88787
+if [ $backup_prog_rc -eq 0 -a "$backup_log_message" ] ; then
f88787
+	LogPrint "$backup_log_message in $transfertime seconds."
f88787
 elif [ "$size" ]; then
f88787
-	LogPrint "Archived $((size/1024/1024)) MiB in $((transfertime)) seconds [avg $((size/1024/transfertime)) KiB/sec]"
f88787
+	LogPrint "Backed up $((size/1024/1024)) MiB in $((transfertime)) seconds [avg $((size/1024/transfertime)) KiB/sec]"
f88787
 fi
f88787
 
f88787
diff --git a/usr/share/rear/backup/RSYNC/default/700_copy_backup_log.sh b/usr/share/rear/backup/RSYNC/default/700_copy_backup_log.sh
f88787
index 01801a4e..b90d459b 100644
f88787
--- a/usr/share/rear/backup/RSYNC/default/700_copy_backup_log.sh
f88787
+++ b/usr/share/rear/backup/RSYNC/default/700_copy_backup_log.sh
f88787
@@ -1,6 +1,8 @@
f88787
 
f88787
 # copy the backup.log & rear.log file to remote destination with timestamp added
f88787
-Timestamp=$( date +%Y%m%d.%H%M )
f88787
+local timestamp
f88787
+
f88787
+timestamp=$( date +%Y%m%d.%H%M )
f88787
 
f88787
 # compress the log file first
f88787
 gzip "$TMP_DIR/$BACKUP_PROG_ARCHIVE.log" || Error "Failed to 'gzip $TMP_DIR/$BACKUP_PROG_ARCHIVE.log'"
f88787
@@ -10,15 +12,15 @@ case $RSYNC_PROTO in
f88787
         # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
f88787
         # or remove it according to https://github.com/rear/rear/issues/1395
f88787
         $BACKUP_PROG -a "${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log.gz" \
f88787
-        "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/${BACKUP_PROG_ARCHIVE}-${Timestamp}.log.gz" 2>/dev/null
f88787
+        "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/${BACKUP_PROG_ARCHIVE}-${timestamp}.log.gz" 2>/dev/null
f88787
 
f88787
-        $BACKUP_PROG -a "$RUNTIME_LOGFILE" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/rear-${Timestamp}.log" 2>/dev/null
f88787
+        $BACKUP_PROG -a "$RUNTIME_LOGFILE" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/rear-${timestamp}.log" 2>/dev/null
f88787
         ;;
f88787
     (rsync)
f88787
-        $BACKUP_PROG -a "${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log.gz" ${BACKUP_RSYNC_OPTIONS[@]} \
f88787
-        "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/${BACKUP_PROG_ARCHIVE}-${Timestamp}.log.gz"
f88787
+        $BACKUP_PROG -a "${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log.gz" "${BACKUP_RSYNC_OPTIONS[@]}" \
f88787
+        "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/${BACKUP_PROG_ARCHIVE}-${timestamp}.log.gz"
f88787
 
f88787
-        $BACKUP_PROG -a "$RUNTIME_LOGFILE" ${BACKUP_RSYNC_OPTIONS[@]} "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}//rear-${Timestamp}.log"
f88787
+        $BACKUP_PROG -a "$RUNTIME_LOGFILE" "${BACKUP_RSYNC_OPTIONS[@]}" "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}//rear-${timestamp}.log"
f88787
         ;;
f88787
 esac
f88787
 
f88787
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
f88787
index 455aa3ce..0c230f38 100644
f88787
--- a/usr/share/rear/conf/default.conf
f88787
+++ b/usr/share/rear/conf/default.conf
f88787
@@ -1106,7 +1106,8 @@ BACKUP_ONLY_EXCLUDE="no"
f88787
 MANUAL_INCLUDE=NO
f88787
 # Disable SELinux policy during backup with NETFS or RSYNC (default yes)
f88787
 BACKUP_SELINUX_DISABLE=1
f88787
-# Enable integrity check of the backup archive (only with BACKUP=NETFS and BACKUP_PROG=tar)
f88787
+# Enable integrity check of the backup archive (full check only with BACKUP=NETFS and BACKUP_PROG=tar,
f88787
+# with BACKUP=rsync or BACKUP_PROG=rsync it only checks whether rsync completed the restore successfully)
f88787
 BACKUP_INTEGRITY_CHECK=
f88787
 # Define BACKUP_TYPE.
f88787
 # By default BACKUP_TYPE is empty which means "rear mkbackup" will create a full backup.
f88787
diff --git a/usr/share/rear/output/RSYNC/default/200_make_prefix_dir.sh b/usr/share/rear/output/RSYNC/default/200_make_prefix_dir.sh
f88787
index 32ac391d..519febf5 100644
f88787
--- a/usr/share/rear/output/RSYNC/default/200_make_prefix_dir.sh
f88787
+++ b/usr/share/rear/output/RSYNC/default/200_make_prefix_dir.sh
f88787
@@ -2,21 +2,19 @@
f88787
 # RSYNC_PREFIX=$HOSTNAME as set in default.conf
f88787
 
f88787
 # create temporary local work-spaces to collect files (we already make the remote backup dir with the correct mode!!)
f88787
-mkdir -p $v -m0750 "${TMP_DIR}/rsync/${RSYNC_PREFIX}" >&2
f88787
-StopIfError "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}'"
f88787
-mkdir -p $v -m0755 "${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup" >&2
f88787
-StopIfError "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup'"
f88787
+mkdir -p $v -m0750 "${TMP_DIR}/rsync/${RSYNC_PREFIX}" >&2 || Error "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}'"
f88787
+mkdir -p $v -m0755 "${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup" >&2 || Error "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup'"
f88787
 
f88787
 case $RSYNC_PROTO in
f88787
 
f88787
 	(ssh)
f88787
-		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}" >/dev/null 2>&1
f88787
-		StopIfError "Could not create '${RSYNC_PATH}/${RSYNC_PREFIX}' on remote ${RSYNC_HOST}"
f88787
+		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}" >/dev/null 2>&1 \
f88787
+                    || Error "Could not create '${RSYNC_PATH}/${RSYNC_PREFIX}' on remote ${RSYNC_HOST}"
f88787
 		;;
f88787
 
f88787
 	(rsync)
f88787
-		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" ${BACKUP_RSYNC_OPTIONS[@]} "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/" >/dev/null
f88787
-		StopIfError "Could not create '${RSYNC_PATH}/${RSYNC_PREFIX}' on remote ${RSYNC_HOST}"
f88787
+		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "${BACKUP_RSYNC_OPTIONS[@]}" "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/" >/dev/null \
f88787
+                    || Error "Could not create '${RSYNC_PATH}/${RSYNC_PREFIX}' on remote ${RSYNC_HOST}"
f88787
 		;;
f88787
 
f88787
 esac
f88787
diff --git a/usr/share/rear/output/RSYNC/default/900_copy_result_files.sh b/usr/share/rear/output/RSYNC/default/900_copy_result_files.sh
f88787
index c7b430d8..96b62da1 100644
f88787
--- a/usr/share/rear/output/RSYNC/default/900_copy_result_files.sh
f88787
+++ b/usr/share/rear/output/RSYNC/default/900_copy_result_files.sh
f88787
@@ -5,19 +5,19 @@ LogPrint "Copying resulting files to $OUTPUT_URL location"
f88787
 
f88787
 # if called as mkbackuponly then we just don't have any result files.
f88787
 if test "$RESULT_FILES" ; then
f88787
-    Log "Copying files '${RESULT_FILES[@]}' to $OUTPUT_URL location"
f88787
-    cp $v "${RESULT_FILES[@]}" "${TMP_DIR}/rsync/${RSYNC_PREFIX}/"
f88787
-    StopIfError "Could not copy files to local rsync location"
f88787
+    Log "Copying files '${RESULT_FILES[*]}' to $OUTPUT_URL location"
f88787
+    cp $v "${RESULT_FILES[@]}" "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" \
f88787
+        || Error "Could not copy files to local rsync location"
f88787
 fi
f88787
 
f88787
-echo "$VERSION_INFO" >"${TMP_DIR}/rsync/${RSYNC_PREFIX}/VERSION"
f88787
-StopIfError "Could not create VERSION file on local rsync location"
f88787
+echo "$VERSION_INFO" >"${TMP_DIR}/rsync/${RSYNC_PREFIX}/VERSION" \
f88787
+    || Error "Could not create VERSION file on local rsync location"
f88787
 
f88787
-cp $v $(get_template "RESULT_usage_$OUTPUT.txt") "${TMP_DIR}/rsync/${RSYNC_PREFIX}/README"
f88787
-StopIfError "Could not copy usage file to local rsync location"
f88787
+cp $v $(get_template "RESULT_usage_$OUTPUT.txt") "${TMP_DIR}/rsync/${RSYNC_PREFIX}/README" \
f88787
+    || Error "Could not copy usage file to local rsync location"
f88787
 
f88787
-cat "$RUNTIME_LOGFILE" >"${TMP_DIR}/rsync/${RSYNC_PREFIX}/rear.log"
f88787
-StopIfError "Could not copy $RUNTIME_LOGFILE to local rsync location"
f88787
+cat "$RUNTIME_LOGFILE" >"${TMP_DIR}/rsync/${RSYNC_PREFIX}/rear.log" \
f88787
+    || Error "Could not copy $RUNTIME_LOGFILE to local rsync location"
f88787
 
f88787
 case $RSYNC_PROTO in
f88787
 
f88787
@@ -25,20 +25,20 @@ case $RSYNC_PROTO in
f88787
     Log "$BACKUP_PROG -a ${TMP_DIR}/rsync/${RSYNC_PREFIX}/ ${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/"
f88787
     # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
f88787
     # or remove it according to https://github.com/rear/rear/issues/1395
f88787
-    $BACKUP_PROG -a "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/" 2>/dev/null
f88787
-    StopIfError "Could not copy '${RESULT_FILES[@]}' to $OUTPUT_URL location"
f88787
+    $BACKUP_PROG -a "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/" 2>/dev/null \
f88787
+        || Error "Could not copy '${RESULT_FILES[*]}' to $OUTPUT_URL location"
f88787
     ;;
f88787
 
f88787
     (rsync)
f88787
-    Log "$BACKUP_PROG -a ${TMP_DIR}/rsync/${RSYNC_PREFIX}/ ${BACKUP_RSYNC_OPTIONS[@]} ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/"
f88787
+    Log "$BACKUP_PROG -a ${TMP_DIR}/rsync/${RSYNC_PREFIX}/ ${BACKUP_RSYNC_OPTIONS[*]} ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/"
f88787
     # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
f88787
     # or remove it according to https://github.com/rear/rear/issues/1395
f88787
-    $BACKUP_PROG -a "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" ${BACKUP_RSYNC_OPTIONS[@]} "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/" 2>/dev/null
f88787
-    StopIfError "Could not copy '${RESULT_FILES[@]}' to $OUTPUT_URL location"
f88787
+    $BACKUP_PROG -a "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" "${BACKUP_RSYNC_OPTIONS[@]}" "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/" 2>/dev/null \
f88787
+        || Error "Could not copy '${RESULT_FILES[*]}' to $OUTPUT_URL location"
f88787
     ;;
f88787
 
f88787
 esac
f88787
 
f88787
 # cleanup the temporary space (need it for the log file during backup)
f88787
-rm -rf "${TMP_DIR}/rsync/${RSYNC_PREFIX}/"
f88787
-LogIfError "Could not cleanup temoprary rsync space: ${TMP_DIR}/rsync/${RSYNC_PREFIX}/"
f88787
+rm -rf "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" \
f88787
+    || Log "Could not cleanup temporary rsync space: ${TMP_DIR}/rsync/${RSYNC_PREFIX}/"
f88787
diff --git a/usr/share/rear/prep/NETFS/default/400_automatic_exclude_recreate.sh b/usr/share/rear/prep/NETFS/default/400_automatic_exclude_recreate.sh
f88787
index fadf9d72..3c719c44 100644
f88787
--- a/usr/share/rear/prep/NETFS/default/400_automatic_exclude_recreate.sh
f88787
+++ b/usr/share/rear/prep/NETFS/default/400_automatic_exclude_recreate.sh
f88787
@@ -31,7 +31,7 @@ case $scheme in
f88787
         backup_directory_mountpoint=$( df -P "$backup_directory" | tail -1 | awk '{print $6}' )
f88787
         test "/" = "$backup_directory_mountpoint" && Error "URL '$BACKUP_URL' has the backup directory '$backup_directory' in the '/' filesystem which is forbidden."
f88787
         # When the mountpoint of the backup directory is not yet excluded add its mountpoint to the EXCLUDE_RECREATE array:
f88787
-        if ! grep -q "$backup_directory_mountpoint" <<< $( echo ${EXCLUDE_RECREATE[@]} ) ; then
f88787
+        if ! grep -q "$backup_directory_mountpoint" <<< "${EXCLUDE_RECREATE[*]}" ; then
f88787
             EXCLUDE_RECREATE+=( "fs:$backup_directory_mountpoint" )
f88787
         fi
f88787
         ;;
f88787
diff --git a/usr/share/rear/prep/RSYNC/GNU/Linux/200_selinux_in_use.sh b/usr/share/rear/prep/RSYNC/GNU/Linux/200_selinux_in_use.sh
f88787
index ac26edfa..eb7df29e 100644
f88787
--- a/usr/share/rear/prep/RSYNC/GNU/Linux/200_selinux_in_use.sh
f88787
+++ b/usr/share/rear/prep/RSYNC/GNU/Linux/200_selinux_in_use.sh
f88787
@@ -33,7 +33,7 @@ case $(basename $BACKUP_PROG) in
f88787
 			touch $TMP_DIR/force.autorelabel	# after reboot the restored system do a forced SELinux relabeling
f88787
 		else
f88787
 			# if --xattrs is already set; no need to do it again
f88787
-			if ! grep -q xattrs <<< $(echo ${BACKUP_RSYNC_OPTIONS[@]}); then
f88787
+			if ! grep -q xattrs <<< "${BACKUP_RSYNC_OPTIONS[*]}" ; then
f88787
 				BACKUP_RSYNC_OPTIONS+=( --xattrs )
f88787
 			fi
f88787
 			RSYNC_SELINUX=1		# variable used in recover mode (means using xattr and not disable SELinux)
f88787
diff --git a/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh b/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh
f88787
index b8535352..c964a148 100644
f88787
--- a/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh
f88787
+++ b/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh
f88787
@@ -33,22 +33,20 @@ RSYNC_PORT=873                  # default port (of rsync server)
f88787
 RSYNC_PATH=
f88787
 
f88787
 
f88787
-echo $BACKUP_URL | egrep -q '(::)'      # new style '::' means rsync protocol
f88787
-if [[ $? -eq 0 ]]; then
f88787
+if egrep -q '(::)' <<< $BACKUP_URL ; then # new style '::' means rsync protocol
f88787
     RSYNC_PROTO=rsync
f88787
 else
f88787
     RSYNC_PROTO=ssh
f88787
 fi
f88787
 
f88787
-echo $host | grep -q '@'
f88787
-if [[ $? -eq 0 ]]; then
f88787
+if grep -q '@' <<< $host ; then
f88787
     RSYNC_USER="${host%%@*}"    # grab user name
f88787
 else
f88787
     RSYNC_USER=root
f88787
 fi
f88787
 
f88787
 # remove USER@ if present (we don't need it anymore)
f88787
-tmp2="${host#*@}"
f88787
+local tmp2="${host#*@}"
f88787
 
f88787
 case "$RSYNC_PROTO" in
f88787
 
f88787
@@ -56,8 +54,7 @@ case "$RSYNC_PROTO" in
f88787
         # tmp2=witsbebelnx02::backup or tmp2=witsbebelnx02::
f88787
         RSYNC_HOST="${tmp2%%::*}"
f88787
         # path=/gdhaese1@witsbebelnx02::backup or path=/backup
f88787
-        echo $path | grep -q '::'
f88787
-        if [[ $? -eq 0 ]]; then
f88787
+        if grep -q '::' <<< $path ; then
f88787
             RSYNC_PATH="${path##*::}"
f88787
         else
f88787
             RSYNC_PATH="${path##*/}"
f88787
@@ -79,8 +76,7 @@ esac
f88787
 
f88787
 # check if host is reachable
f88787
 if test "$PING" ; then
f88787
-    ping -c 2 "$RSYNC_HOST" >/dev/null
f88787
-    StopIfError "Backup host [$RSYNC_HOST] not reachable."
f88787
+    ping -c 2 "$RSYNC_HOST" >/dev/null || Error "Backup host [$RSYNC_HOST] not reachable."
f88787
 else
f88787
     Log "Skipping ping test"
f88787
 fi
f88787
@@ -89,15 +85,15 @@ fi
f88787
 case "$RSYNC_PROTO" in
f88787
 
f88787
     (rsync)
f88787
-        Log "Test: $BACKUP_PROG ${BACKUP_RSYNC_OPTIONS[@]} ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/"
f88787
-        $BACKUP_PROG ${BACKUP_RSYNC_OPTIONS[@]} ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/ >/dev/null
f88787
-        StopIfError "Rsync daemon not running on $RSYNC_HOST"
f88787
+        Log "Test: $BACKUP_PROG ${BACKUP_RSYNC_OPTIONS[*]} ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/"
f88787
+        $BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/ >/dev/null \
f88787
+            || Error "Rsync daemon not running on $RSYNC_HOST"
f88787
         ;;
f88787
 
f88787
     (ssh)
f88787
         Log "Test: ssh ${RSYNC_USER}@${RSYNC_HOST} /bin/true"
f88787
-        ssh ${RSYNC_USER}@${RSYNC_HOST} /bin/true >/dev/null 2>&1
f88787
-        StopIfError "Secure shell connection not setup properly [$RSYNC_USER@$RSYNC_HOST]"
f88787
+        ssh ${RSYNC_USER}@${RSYNC_HOST} /bin/true >/dev/null 2>&1 \
f88787
+            || Error "Secure shell connection not setup properly [$RSYNC_USER@$RSYNC_HOST]"
f88787
         ;;
f88787
 
f88787
 esac
f88787
diff --git a/usr/share/rear/prep/RSYNC/default/150_check_rsync_protocol_version.sh b/usr/share/rear/prep/RSYNC/default/150_check_rsync_protocol_version.sh
f88787
index 446dd736..e9103531 100644
f88787
--- a/usr/share/rear/prep/RSYNC/default/150_check_rsync_protocol_version.sh
f88787
+++ b/usr/share/rear/prep/RSYNC/default/150_check_rsync_protocol_version.sh
f88787
@@ -2,15 +2,17 @@
f88787
 # This file is part of Relax-and-Recover, licensed under the GNU General
f88787
 # Public License. Refer to the included COPYING for full text of license.
f88787
 # try to grab the rsync protocol version of rsync on the remote server
f88787
+
f88787
+local remote_mountpoint
f88787
+
f88787
 if [ -z "$RSYNC_PROTOCOL_VERSION" ]; then
f88787
 
f88787
     case $RSYNC_PROTO in
f88787
 
f88787
     (ssh)
f88787
-        ssh ${RSYNC_USER}@${RSYNC_HOST} rsync --version >"$TMP_DIR/rsync_protocol" 2>&1
f88787
-        StopIfError "Secure shell connection not setup properly [$RSYNC_USER@$RSYNC_HOST]"
f88787
-        grep -q "protocol version" "$TMP_DIR/rsync_protocol"
f88787
-        if [ $? -eq 0 ]; then
f88787
+        ssh ${RSYNC_USER}@${RSYNC_HOST} rsync --version >"$TMP_DIR/rsync_protocol" 2>&1 \
f88787
+            || Error "Secure shell connection not setup properly [$RSYNC_USER@$RSYNC_HOST]"
f88787
+        if grep -q "protocol version" "$TMP_DIR/rsync_protocol" ; then
f88787
             RSYNC_PROTOCOL_VERSION=$(grep 'protocol version' "$TMP_DIR/rsync_protocol" | awk '{print $6}')
f88787
         else
f88787
             RSYNC_PROTOCOL_VERSION=29   # being conservative (old rsync version < 3.0)
f88787
@@ -30,25 +32,21 @@ else
f88787
 
f88787
 fi
f88787
 
f88787
-if [ "${RSYNC_USER}" != "root" ]; then
f88787
+if [ "${RSYNC_USER}" != "root" -a $RSYNC_PROTO = "ssh" ]; then
f88787
     if [ $RSYNC_PROTOCOL_VERSION -gt 29 ]; then
f88787
         if grep -q "no xattrs" "$TMP_DIR/rsync_protocol"; then
f88787
             # no xattrs available in remote rsync, so --fake-super is not possible
f88787
             Error "rsync --fake-super not possible on system ($RSYNC_HOST) (no xattrs compiled in rsync)"
f88787
         else
f88787
             # when using --fake-super we must have user_xattr mount options on the remote mntpt
f88787
-            _mntpt=$(ssh ${RSYNC_USER}@${RSYNC_HOST} 'cd ${RSYNC_PATH}; df -P .' 2>/dev/null | tail -1 | awk '{print $6}')
f88787
-            ssh ${RSYNC_USER}@${RSYNC_HOST} "cd ${RSYNC_PATH} && touch .is_xattr_supported && setfattr -n user.comment -v 'File created by ReaR to test if this filesystems supports extended attributes.' .is_xattr_supported && getfattr -n user.comment .is_xattr_supported 1>/dev/null; find .is_xattr_supported -empty -delete"
f88787
-            StopIfError "Remote file system $_mntpt does not have user_xattr mount option set!"
f88787
-            #BACKUP_RSYNC_OPTIONS+=( --xattrs --rsync-path="""rsync --fake-super""" )
f88787
+            remote_mountpoint=$(ssh ${RSYNC_USER}@${RSYNC_HOST} 'cd ${RSYNC_PATH}; df -P .' 2>/dev/null | tail -1 | awk '{print $6}')
f88787
+            ssh ${RSYNC_USER}@${RSYNC_HOST} "cd ${RSYNC_PATH} && touch .is_xattr_supported && setfattr -n user.comment -v 'File created by ReaR to test if this filesystems supports extended attributes.' .is_xattr_supported && getfattr -n user.comment .is_xattr_supported 1>/dev/null; find .is_xattr_supported -empty -delete" \
f88787
+                || Error "Remote file system $remote_mountpoint does not have user_xattr mount option set!"
f88787
+            #BACKUP_RSYNC_OPTIONS+=( --xattrs --rsync-path="rsync --fake-super" )
f88787
             # see issue #366 for explanation of removing --xattrs
f88787
-            BACKUP_RSYNC_OPTIONS+=( --rsync-path="""rsync --fake-super""" )
f88787
+            BACKUP_RSYNC_OPTIONS+=( --rsync-path="rsync --fake-super" )
f88787
         fi
f88787
     else
f88787
-        if [ ${BACKUP_RSYNC_OPTIONS[@]/--fake-super/} != ${BACKUP_RSUNC_OPTIONS[@]} ]; then
f88787
-            Error "rsync --fake-super not possible on system ($RSYNC_HOST) (please upgrade rsync to 3.x)"
f88787
-        else
f88787
-            Log "Warning: rsync --fake-super not possible on system ($RSYNC_HOST) (please upgrade rsync to 3.x)"
f88787
-        fi
f88787
+        Error "rsync --fake-super not possible on system ($RSYNC_HOST) (please upgrade rsync to 3.x)"
f88787
     fi
f88787
 fi
f88787
diff --git a/usr/share/rear/restore/DUPLICITY/default/400_restore_duplicity.sh b/usr/share/rear/restore/DUPLICITY/default/400_restore_duplicity.sh
f88787
index 0a9c9648..220ccc57 100644
f88787
--- a/usr/share/rear/restore/DUPLICITY/default/400_restore_duplicity.sh
f88787
+++ b/usr/share/rear/restore/DUPLICITY/default/400_restore_duplicity.sh
f88787
@@ -5,6 +5,8 @@
f88787
 # Restore from remote backup via DUPLICIY over rsync
f88787
 
f88787
 if [ "$BACKUP_PROG" = "duplicity" ]; then
f88787
+    local backup_prog_rc
f88787
+    local restore_log_message
f88787
 
f88787
     LogPrint "========================================================================"
f88787
     LogPrint "Restoring backup with $BACKUP_PROG from '$BACKUP_DUPLICITY_URL'"
f88787
@@ -49,7 +51,8 @@ if [ "$BACKUP_PROG" = "duplicity" ]; then
f88787
         LogPrint "with CMD: $DUPLICITY_PROG -v 5 $GPG_KEY --force --tempdir=$DUPLICITY_TEMPDIR $BACKUP_DUPLICITY_URL/$HOSTNAME/ $TARGET_FS_ROOT"
f88787
         $DUPLICITY_PROG -v 5 $GPG_KEY --force --tempdir="$DUPLICITY_TEMPDIR" $BACKUP_DUPLICITY_URL/$HOSTNAME/ $TARGET_FS_ROOT 0<&6 | tee $TMP_DIR/duplicity-restore.log
f88787
     fi
f88787
-    _rc=$?
f88787
+    # FIXME: this collects the exit code from "tee", not from $DUPLICITY_PROG
f88787
+    backup_prog_rc=$?
f88787
 
f88787
     transfertime="$((SECONDS-$starttime))"
f88787
     sleep 1
f88787
@@ -65,20 +68,20 @@ if [ "$BACKUP_PROG" = "duplicity" ]; then
f88787
     LogPrint "========================================================================"
f88787
 
f88787
 
f88787
-    if [ "$_rc" -gt 0 ]; then
f88787
+    if [ "$backup_prog_rc" -gt 0 ]; then
f88787
         LogPrint "WARNING !
f88787
     There was an error while restoring the archive.
f88787
     Please check '$RUNTIME_LOGFILE' and $TMP_DIR/duplicity-restore.log for more information.
f88787
     You should also manually check the restored system to see whether it is complete.
f88787
     "
f88787
 
f88787
-        _message="$(tail -14 ${TMP_DIR}/duplicity-restore.log)"
f88787
+        restore_log_message="$(tail -14 ${TMP_DIR}/duplicity-restore.log)"
f88787
 
f88787
         LogPrint "Last 14 Lines of ${TMP_DIR}/duplicity-restore.log:"
f88787
-        LogPrint "$_message"
f88787
+        LogPrint "$restore_log_message"
f88787
     fi
f88787
 
f88787
-    if [ $_rc -eq 0 ] ; then
f88787
+    if [ $backup_prog_rc -eq 0 ] ; then
f88787
         LogPrint "Restore completed in $transfertime seconds."
f88787
     fi
f88787
 
f88787
diff --git a/usr/share/rear/restore/RBME/default/400_restore_backup.sh b/usr/share/rear/restore/RBME/default/400_restore_backup.sh
f88787
index 28a3c354..3e97e16b 100644
f88787
--- a/usr/share/rear/restore/RBME/default/400_restore_backup.sh
f88787
+++ b/usr/share/rear/restore/RBME/default/400_restore_backup.sh
f88787
@@ -2,6 +2,8 @@ if [[ -z "$RBME_BACKUP" ]] ; then
f88787
     Error "No RBME backup selected (BACKUP_URL?). Aborting."
f88787
 fi
f88787
 
f88787
+local backup_prog_rc
f88787
+
f88787
 scheme=$(url_scheme "$BACKUP_URL")
f88787
 
f88787
 LogPrint "Restoring from backup $RBME_BACKUP."
f88787
@@ -43,11 +45,11 @@ transfertime="$((SECONDS-starttime))"
f88787
 # harvest return code from background job. The kill -0 $BackupPID loop above should
f88787
 # have made sure that this wait won't do any real "waiting" :-)
f88787
 wait $BackupPID
f88787
-_rc=$?
f88787
+backup_prog_rc=$?
f88787
 
f88787
 sleep 1
f88787
-test "$_rc" -gt 0 && LogPrint "WARNING !
f88787
-There was an error (${rsync_err_msg[$_rc]}) while restoring the archive.
f88787
+test "$backup_prog_rc" -gt 0 && LogPrint "WARNING !
f88787
+There was an error (${rsync_err_msg[$backup_prog_rc]}) while restoring the archive.
f88787
 Please check '$RUNTIME_LOGFILE' for more information. You should also
f88787
 manually check the restored system to see whether it is complete.
f88787
 "
f88787
diff --git a/usr/share/rear/restore/RSYNC/default/200_remove_relative_rsync_option.sh b/usr/share/rear/restore/RSYNC/default/200_remove_relative_rsync_option.sh
f88787
index 53915322..a792f195 100644
f88787
--- a/usr/share/rear/restore/RSYNC/default/200_remove_relative_rsync_option.sh
f88787
+++ b/usr/share/rear/restore/RSYNC/default/200_remove_relative_rsync_option.sh
f88787
@@ -4,11 +4,11 @@
f88787
 # without the --relative option ; my feeling says it is better to remove it from array BACKUP_RSYNC_OPTIONS
f88787
 # If I'm wrong please let us know (use issue mentioned above to comment)
f88787
 
f88787
-if grep -q relative <<< $(echo ${BACKUP_RSYNC_OPTIONS[@]}); then
f88787
+if grep -q -- "--relative" <<< "${BACKUP_RSYNC_OPTIONS[*]}" ; then
f88787
     BACKUP_RSYNC_OPTIONS=( $( RmInArray "--relative" "${BACKUP_RSYNC_OPTIONS[@]}" ) )
f88787
     Log "Removed option '--relative' from the BACKUP_RSYNC_OPTIONS array during $WORKFLOW workflow"
f88787
 fi
f88787
-if grep -q "-R" <<< $(echo ${BACKUP_RSYNC_OPTIONS[@]}); then
f88787
+if grep -q -- "-R" <<< "${BACKUP_RSYNC_OPTIONS[*]}" ; then
f88787
     BACKUP_RSYNC_OPTIONS=( $( RmInArray "-R" "${BACKUP_RSYNC_OPTIONS[@]}" ) )
f88787
     Log "Removed option '-R' from the BACKUP_RSYNC_OPTIONS array during $WORKFLOW workflow"
f88787
 fi
f88787
diff --git a/usr/share/rear/restore/RSYNC/default/400_restore_rsync_backup.sh b/usr/share/rear/restore/RSYNC/default/400_restore_rsync_backup.sh
f88787
index 2a0bf15e..993088be 100644
f88787
--- a/usr/share/rear/restore/RSYNC/default/400_restore_rsync_backup.sh
f88787
+++ b/usr/share/rear/restore/RSYNC/default/400_restore_rsync_backup.sh
f88787
@@ -4,10 +4,10 @@ get_size() {
f88787
 	echo $( stat --format '%s' "$TARGET_FS_ROOT/$1" )
f88787
 }
f88787
 
f88787
-mkdir -p "${TMP_DIR}/rsync/${NETFS_PREFIX}"
f88787
-StopIfError "Could not mkdir '$TMP_DIR/rsync/${NETFS_PREFIX}'"
f88787
+local backup_prog_rc
f88787
+local restore_log_message
f88787
 
f88787
-LogPrint "Restoring $BACKUP_PROG archive from '${RSYNC_HOST}:${RSYNC_PATH}'"
f88787
+LogPrint "Restoring $BACKUP_PROG backup from '${RSYNC_HOST}:${RSYNC_PATH}'"
f88787
 
f88787
 ProgressStart "Restore operation"
f88787
 (
f88787
@@ -33,9 +33,10 @@ ProgressStart "Restore operation"
f88787
 			;;
f88787
 
f88787
 		(*)
f88787
-			# no other backup programs foreseen then rsync so far
f88787
+			# no other backup programs foreseen than rsync so far
f88787
 			:
f88787
 			;;
f88787
+
f88787
 	esac
f88787
 	echo $? >$TMP_DIR/retval
f88787
 ) >"${TMP_DIR}/${BACKUP_PROG_ARCHIVE}-restore.log" &
f88787
@@ -65,6 +66,7 @@ case "$(basename $BACKUP_PROG)" in
f88787
 			ProgressStep
f88787
 		done
f88787
 		;;
f88787
+
f88787
 esac
f88787
 ProgressStop
f88787
 
f88787
@@ -72,20 +74,28 @@ transfertime="$((SECONDS-starttime))"
f88787
 
f88787
 # harvest return code from background job. The kill -0 $BackupPID loop above should
f88787
 # have made sure that this wait won't do any real "waiting" :-)
f88787
-wait $BackupPID
f88787
-_rc=$?
f88787
+wait $BackupPID || LogPrintError "Restore job returned a nonzero exit code $?"
f88787
+# harvest the actual return code of rsync. Finishing the pipeline with an error code above is actually unlikely,
f88787
+# because rsync is not the last command in it. But error returns from rsync are common and must be handled.
f88787
+backup_prog_rc="$(cat $TMP_DIR/retval)"
f88787
 
f88787
 sleep 1
f88787
-test "$_rc" -gt 0 && LogPrint "WARNING !
f88787
-There was an error (${rsync_err_msg[$_rc]}) while restoring the archive.
f88787
+if test "$backup_prog_rc" -gt 0 ; then
f88787
+    # TODO: Shouldn't we tell the user to check ${TMP_DIR}/${BACKUP_PROG_ARCHIVE}-restore.log as well?
f88787
+    LogPrintError "WARNING !
f88787
+There was an error (${rsync_err_msg[$backup_prog_rc]}) while restoring the backup.
f88787
 Please check '$RUNTIME_LOGFILE' for more information. You should also
f88787
 manually check the restored system to see whether it is complete.
f88787
 "
f88787
+    is_true "$BACKUP_INTEGRITY_CHECK" && Error "Integrity check failed, restore aborted because BACKUP_INTEGRITY_CHECK is enabled"
f88787
+fi
f88787
 
f88787
-_message="$(tail -14 ${TMP_DIR}/${BACKUP_PROG_ARCHIVE}-restore.log)"
f88787
+restore_log_message="$(tail -14 ${TMP_DIR}/${BACKUP_PROG_ARCHIVE}-restore.log)"
f88787
 
f88787
-if [ $_rc -eq 0 -a "$_message" ] ; then
f88787
-        LogPrint "$_message in $transfertime seconds."
f88787
+if [ $backup_prog_rc -eq 0 -a "$restore_log_message" ] ; then
f88787
+        LogPrint "$restore_log_message in $transfertime seconds."
f88787
 elif [ "$size" ]; then
f88787
         LogPrint "Restored $((size/1024/1024)) MiB in $((transfertime)) seconds [avg $((size/1024/transfertime)) KiB/sec]"
f88787
 fi
f88787
+
f88787
+return $backup_prog_rc
f88787
diff --git a/usr/share/rear/verify/RSYNC/GNU/Linux/600_check_rsync_xattr.sh b/usr/share/rear/verify/RSYNC/GNU/Linux/600_check_rsync_xattr.sh
f88787
index 3622884a..890161f1 100644
f88787
--- a/usr/share/rear/verify/RSYNC/GNU/Linux/600_check_rsync_xattr.sh
f88787
+++ b/usr/share/rear/verify/RSYNC/GNU/Linux/600_check_rsync_xattr.sh
f88787
@@ -3,8 +3,8 @@
f88787
 [[ $RSYNC_SELINUX ]] && {
f88787
 
f88787
 	# if --xattrs is already set; no need to do it again
f88787
-	if ! grep -q xattrs <<< $(echo ${BACKUP_RSYNC_OPTIONS[@]}); then
f88787
-		RSYNC_OPTIONS=( "${BACKUP_RSYNC_OPTIONS[@]}" --xattrs )
f88787
+	if ! grep -q xattrs <<< "${BACKUP_RSYNC_OPTIONS[*]}" ; then
f88787
+		BACKUP_RSYNC_OPTIONS+=( --xattrs )
f88787
 	fi
f88787
 
f88787
 }
f88787
diff --git a/usr/share/rear/verify/RSYNC/default/550_check_remote_backup_archive.sh b/usr/share/rear/verify/RSYNC/default/550_check_remote_backup_archive.sh
f88787
index 47ed9e02..b2fb72f5 100644
f88787
--- a/usr/share/rear/verify/RSYNC/default/550_check_remote_backup_archive.sh
f88787
+++ b/usr/share/rear/verify/RSYNC/default/550_check_remote_backup_archive.sh
f88787
@@ -3,12 +3,12 @@
f88787
 case $RSYNC_PROTO in
f88787
 
f88787
 	(ssh)
f88787
-		ssh ${RSYNC_USER}@${RSYNC_HOST} "ls -ld ${RSYNC_PATH}/${RSYNC_PREFIX}/backup" >/dev/null 2>&1
f88787
-		StopIfError "Archive not found on [$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}]"
f88787
+		ssh ${RSYNC_USER}@${RSYNC_HOST} "ls -ld ${RSYNC_PATH}/${RSYNC_PREFIX}/backup" >/dev/null 2>&1 \
f88787
+		    || Error "Archive not found on [$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}]"
f88787
 		;;
f88787
 
f88787
 	(rsync)
f88787
-		$BACKUP_PROG "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup" >/dev/null 2>&1
f88787
-		StopIfError "Archive not found on [$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}]"
f88787
+		$BACKUP_PROG "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup" >/dev/null 2>&1 \
f88787
+		    || Error "Archive not found on [$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}]"
f88787
 		;;
f88787
 esac