Blame SOURCES/rsync-output.patch

5d051d
commit e6a9c973dbb7be6e46ed9a7fe34df0635635fed6
5d051d
Author: Johannes Meixner <jsmeix@suse.com>
5d051d
Date:   Tue Jul 12 13:59:28 2022 +0200
5d051d
5d051d
    Merge pull request #2831 from pcahyna/rsync-url-fix-refactor
5d051d
    
5d051d
    Refactor rsync URL support, fixes rsync OUTPUT_URL:
5d051d
    The code to parse rsync:// URLs was BACKUP_URL specific.
5d051d
    If one specified BACKUP=RSYNC and an OUTPUT_URL different from BACKUP_URL,
5d051d
    the OUTPUT_URL was ignored and the output files went to BACKUP_URL.
5d051d
    Fix by introducing generic functions for rsync URL parsing and
5d051d
    use them for both BACKUP_URL and OUTPUT_URL, as appropriate.
5d051d
    Replace all uses of global RSYNC_* variables derived
5d051d
    from BACKUP_URL by those functions.
5d051d
    There also was inconsistent special handling for OUTPUT=PXE which is now removed:
5d051d
    An rsync OUTPUT_URL with OUTPUT=PXE now creates the RSYNC_PREFIX directory
5d051d
    at the destination and the URL is interpreted as in all other cases.
5d051d
    See https://github.com/rear/rear/pull/2831
5d051d
    and https://github.com/rear/rear/issues/2781
5d051d
5d051d
diff --git a/usr/share/rear/backup/NETFS/default/200_check_rsync_relative_option.sh b/usr/share/rear/backup/NETFS/default/200_check_rsync_relative_option.sh
5d051d
deleted file mode 120000
5d051d
index 336b83f5..00000000
5d051d
--- a/usr/share/rear/backup/NETFS/default/200_check_rsync_relative_option.sh
5d051d
+++ /dev/null
5d051d
@@ -1 +0,0 @@
5d051d
-../../RSYNC/default/200_check_rsync_relative_option.sh
5d051d
\ No newline at end of file
5d051d
diff --git a/usr/share/rear/backup/NETFS/default/210_check_rsync_relative_option.sh b/usr/share/rear/backup/NETFS/default/210_check_rsync_relative_option.sh
5d051d
new file mode 120000
5d051d
index 00000000..0570eb44
5d051d
--- /dev/null
5d051d
+++ b/usr/share/rear/backup/NETFS/default/210_check_rsync_relative_option.sh
5d051d
@@ -0,0 +1 @@
5d051d
+../../RSYNC/default/210_check_rsync_relative_option.sh
5d051d
\ No newline at end of file
5d051d
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
5d051d
index 1692ba4c..dd198ede 100644
5d051d
--- a/usr/share/rear/backup/RSYNC/GNU/Linux/610_start_selinux.sh
5d051d
+++ b/usr/share/rear/backup/RSYNC/GNU/Linux/610_start_selinux.sh
5d051d
@@ -6,29 +6,29 @@ local backup_prog_rc
5d051d
 	touch "${TMP_DIR}/selinux.autorelabel"
5d051d
 	cat $TMP_DIR/selinux.mode > $SELINUX_ENFORCE
5d051d
 	Log "Restored original SELinux mode"
5d051d
-	case $RSYNC_PROTO in
5d051d
+	case $(rsync_proto "$BACKUP_URL") in
5d051d
 
5d051d
 	(ssh)
5d051d
 		# for some reason rsync changes the mode of backup after each run to 666
5d051d
                 # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
5d051d
                 # or remove it according to https://github.com/rear/rear/issues/1395
5d051d
-		ssh $RSYNC_USER@$RSYNC_HOST "chmod $v 755 ${RSYNC_PATH}/${RSYNC_PREFIX}/backup" 2>/dev/null
5d051d
+		ssh $(rsync_remote_ssh "$BACKUP_URL") "chmod $v 755 $(rsync_path_full "$BACKUP_URL")/backup" 2>/dev/null
5d051d
 		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" \
5d051d
-		 "$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel" 2>/dev/null
5d051d
+		 "$(rsync_remote_full "$BACKUP_URL")/backup/.autorelabel" 2>/dev/null
5d051d
 		backup_prog_rc=$?
5d051d
 		if [ $backup_prog_rc -ne 0 ]; then
5d051d
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
-			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
5d051d
+			LogPrint "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
+			#StopIfError "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup"
5d051d
 		fi
5d051d
 		;;
5d051d
 
5d051d
 	(rsync)
5d051d
 		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" "${BACKUP_RSYNC_OPTIONS[@]}" \
5d051d
-		 "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel"
5d051d
+		 "$(rsync_remote_full "$BACKUP_URL")/backup/.autorelabel"
5d051d
 		backup_prog_rc=$?
5d051d
 		if [ $backup_prog_rc -ne 0 ]; then
5d051d
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
-			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
5d051d
+			LogPrint "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
+			#StopIfError "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup"
5d051d
 		fi
5d051d
 		;;
5d051d
 
5d051d
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
5d051d
index 9a17d6bb..de57d571 100644
5d051d
--- a/usr/share/rear/backup/RSYNC/GNU/Linux/620_force_autorelabel.sh
5d051d
+++ b/usr/share/rear/backup/RSYNC/GNU/Linux/620_force_autorelabel.sh
5d051d
@@ -4,29 +4,29 @@ local backup_prog_rc
5d051d
 
5d051d
 	> "${TMP_DIR}/selinux.autorelabel"
5d051d
 
5d051d
-	case $RSYNC_PROTO in
5d051d
+	case $(rsync_proto "$BACKUP_URL") in
5d051d
 
5d051d
 	(ssh)
5d051d
 		# for some reason rsync changes the mode of backup after each run to 666
5d051d
                 # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
5d051d
                 # or remove it according to https://github.com/rear/rear/issues/1395
5d051d
-		ssh $RSYNC_USER@$RSYNC_HOST "chmod $v 755 ${RSYNC_PATH}/${RSYNC_PREFIX}/backup" 2>/dev/null
5d051d
+		ssh $(rsync_remote_ssh "$BACKUP_URL") "chmod $v 755 $(rsync_path_full "$BACKUP_URL")/backup" 2>/dev/null
5d051d
 		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" \
5d051d
-		 "$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel" 2>/dev/null
5d051d
+		 "$(rsync_remote_full "$BACKUP_URL")/backup/.autorelabel" 2>/dev/null
5d051d
 		backup_prog_rc=$?
5d051d
 		if [ $backup_prog_rc -ne 0 ]; then
5d051d
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
-			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
5d051d
+			LogPrint "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
+			#StopIfError "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup"
5d051d
 		fi
5d051d
 		;;
5d051d
 
5d051d
 	(rsync)
5d051d
 		$BACKUP_PROG -a "${TMP_DIR}/selinux.autorelabel" "${BACKUP_RSYNC_OPTIONS[@]}" \
5d051d
-		 "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup/.autorelabel"
5d051d
+		 "$(rsync_remote_full "$BACKUP_URL")/backup/.autorelabel"
5d051d
 		backup_prog_rc=$?
5d051d
 		if [ $backup_prog_rc -ne 0 ]; then
5d051d
-			LogPrint "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
-			#StopIfError "Failed to create .autorelabel on ${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
5d051d
+			LogPrint "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup [${rsync_err_msg[$backup_prog_rc]}]"
5d051d
+			#StopIfError "Failed to create .autorelabel on $(rsync_path_full "$BACKUP_URL")/backup"
5d051d
 		fi
5d051d
 		;;
5d051d
 
5d051d
diff --git a/usr/share/rear/backup/RSYNC/default/200_make_prefix_dir.sh b/usr/share/rear/backup/RSYNC/default/200_make_prefix_dir.sh
5d051d
new file mode 100644
5d051d
index 00000000..81aa6879
5d051d
--- /dev/null
5d051d
+++ b/usr/share/rear/backup/RSYNC/default/200_make_prefix_dir.sh
5d051d
@@ -0,0 +1,28 @@
5d051d
+# Create RSYNC_PREFIX/backup on remote rsync server
5d051d
+# RSYNC_PREFIX=$HOSTNAME as set in default.conf
5d051d
+
5d051d
+local proto host
5d051d
+
5d051d
+proto="$(rsync_proto "$BACKUP_URL")"
5d051d
+host="$(rsync_host "$BACKUP_URL")"
5d051d
+
5d051d
+mkdir -p $v -m0750 "${TMP_DIR}/rsync/${RSYNC_PREFIX}" >&2 || Error "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}'"
5d051d
+mkdir -p $v -m0755 "${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup" >&2 || Error "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup'"
5d051d
+
5d051d
+case $proto in
5d051d
+
5d051d
+	(ssh)
5d051d
+		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "$(rsync_remote "$BACKUP_URL")" >/dev/null 2>&1 \
5d051d
+                    || Error "Could not create '$(rsync_path_full "$BACKUP_URL")' on remote ${host}"
5d051d
+		;;
5d051d
+
5d051d
+	(rsync)
5d051d
+		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "${BACKUP_RSYNC_OPTIONS[@]}" "$(rsync_remote "$BACKUP_URL")/" >/dev/null \
5d051d
+                    || Error "Could not create '$(rsync_path_full "$BACKUP_URL")' on remote ${host}"
5d051d
+		;;
5d051d
+
5d051d
+esac
5d051d
+
5d051d
+# We don't need it anymore, from now we operate on the remote copy
5d051d
+rmdir $v "${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup"
5d051d
+rmdir $v "${TMP_DIR}/rsync/${RSYNC_PREFIX}"
5d051d
diff --git a/usr/share/rear/backup/RSYNC/default/200_check_rsync_relative_option.sh b/usr/share/rear/backup/RSYNC/default/210_check_rsync_relative_option.sh
5d051d
similarity index 91%
5d051d
rename from usr/share/rear/backup/RSYNC/default/200_check_rsync_relative_option.sh
5d051d
rename to usr/share/rear/backup/RSYNC/default/210_check_rsync_relative_option.sh
5d051d
index cedee9ce..692616b7 100644
5d051d
--- a/usr/share/rear/backup/RSYNC/default/200_check_rsync_relative_option.sh
5d051d
+++ b/usr/share/rear/backup/RSYNC/default/210_check_rsync_relative_option.sh
5d051d
@@ -1,4 +1,4 @@
5d051d
-# 200_check_rsync_relative_option.sh
5d051d
+# 210_check_rsync_relative_option.sh
5d051d
 # See issue #871 for details
5d051d
 
5d051d
 # check for the --relative option in BACKUP_RSYNC_OPTIONS array
5d051d
diff --git a/usr/share/rear/backup/RSYNC/default/450_calculate_req_space.sh b/usr/share/rear/backup/RSYNC/default/450_calculate_req_space.sh
5d051d
index eb99dbf6..037e49c0 100644
5d051d
--- a/usr/share/rear/backup/RSYNC/default/450_calculate_req_space.sh
5d051d
+++ b/usr/share/rear/backup/RSYNC/default/450_calculate_req_space.sh
5d051d
@@ -1,6 +1,12 @@
5d051d
 # here we will calculate the space required to hold the backup archive on the remote rsync system
5d051d
 # This file is part of Relax-and-Recover, licensed under the GNU General
5d051d
 # Public License. Refer to the included COPYING for full text of license.
5d051d
+local proto host path
5d051d
+
5d051d
+proto="$(rsync_proto "$BACKUP_URL")"
5d051d
+host="$(rsync_host "$BACKUP_URL")"
5d051d
+path="$(rsync_path "$BACKUP_URL")"
5d051d
+
5d051d
 _local_size=0
5d051d
 _remote_size=0
5d051d
 while read -r ; do
5d051d
@@ -13,17 +19,17 @@ while read -r ; do
5d051d
 done < $TMP_DIR/backup-include.txt
5d051d
 LogPrint "Estimated size of local file systems is $(( _local_size / 1024 )) MB"
5d051d
 
5d051d
-case $RSYNC_PROTO in
5d051d
+case $proto in
5d051d
     (ssh)
5d051d
-        LogPrint "Calculating size of $RSYNC_HOST:$RSYNC_PATH"
5d051d
-        ssh -l $RSYNC_USER $RSYNC_HOST "df -P $RSYNC_PATH" >$TMP_DIR/rs_size
5d051d
-        StopIfError "Failed to determine size of $RSYNC_PATH"
5d051d
+        LogPrint "Calculating size of ${host}:${path}"
5d051d
+        ssh $(rsync_remote_ssh "$BACKUP_URL") "df -P ${path}" >$TMP_DIR/rs_size
5d051d
+        StopIfError "Failed to determine size of ${path}"
5d051d
         _div=1 # 1024-blocks
5d051d
         grep -q "512-blocks" $TMP_DIR/rs_size && _div=2 # HPUX: divide with 2 to get kB size
5d051d
         _remote_size=$( tail -n 1 $TMP_DIR/rs_size | awk '{print $2}' )
5d051d
         _remote_size=$(( _remote_size / _div ))
5d051d
         [[ $_remote_size -gt $_local_size ]]
5d051d
-        StopIfError "Not enough disk space available on $RSYNC_HOST:$RSYNC_PATH ($_remote_size < $_local_size)"
5d051d
+        StopIfError "Not enough disk space available on ${host}:${path} ($_remote_size < $_local_size)"
5d051d
         ;;
5d051d
     (rsync)
5d051d
         # TODO: how can we calculate the free size on remote system via rsync protocol??
5d051d
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
5d051d
index 750a04ca..aa8192c0 100644
5d051d
--- a/usr/share/rear/backup/RSYNC/default/500_make_rsync_backup.sh
5d051d
+++ b/usr/share/rear/backup/RSYNC/default/500_make_rsync_backup.sh
5d051d
@@ -5,6 +5,11 @@
5d051d
 local backup_prog_rc
5d051d
 local backup_log_message
5d051d
 
5d051d
+local host path
5d051d
+
5d051d
+host="$(rsync_host "$BACKUP_URL")"
5d051d
+path="$(rsync_path "$BACKUP_URL")"
5d051d
+
5d051d
 Log "Include list:"
5d051d
 while read -r ; do
5d051d
 	Log "  $REPLY"
5d051d
@@ -14,26 +19,27 @@ while read -r ; do
5d051d
 	Log " $REPLY"
5d051d
 done < $TMP_DIR/backup-exclude.txt
5d051d
 
5d051d
-LogPrint "Creating $BACKUP_PROG backup on '${RSYNC_HOST}:${RSYNC_PATH}'"
5d051d
+LogPrint "Creating $BACKUP_PROG backup on '${host}:${path}'"
5d051d
 
5d051d
 ProgressStart "Running backup operation"
5d051d
 (
5d051d
 	case "$(basename $BACKUP_PROG)" in
5d051d
 
5d051d
 		(rsync)
5d051d
+			# We are in a subshell, so this change will not propagate to later scripts
5d051d
 			BACKUP_RSYNC_OPTIONS+=( --one-file-system --delete --exclude-from=$TMP_DIR/backup-exclude.txt --delete-excluded )
5d051d
 
5d051d
-			case $RSYNC_PROTO in
5d051d
+			case $(rsync_proto "$BACKUP_URL") in
5d051d
 
5d051d
 				(ssh)
5d051d
-					Log $BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" $(cat $TMP_DIR/backup-include.txt) "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
5d051d
+					Log $BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" $(cat $TMP_DIR/backup-include.txt) "$(rsync_remote_full "$BACKUP_URL")/backup"
5d051d
 					$BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" $(cat $TMP_DIR/backup-include.txt) \
5d051d
-					"${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
5d051d
+					"$(rsync_remote_full "$BACKUP_URL")/backup"
5d051d
 					;;
5d051d
 
5d051d
 				(rsync)
5d051d
 					$BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" $(cat $TMP_DIR/backup-include.txt) \
5d051d
-					"${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup"
5d051d
+					"$(rsync_remote_full "$BACKUP_URL")/backup"
5d051d
 					;;
5d051d
 
5d051d
 			esac
5d051d
@@ -57,11 +63,11 @@ get_size() {
5d051d
 }
5d051d
 
5d051d
 check_remote_df() {
5d051d
-	echo $(ssh ${RSYNC_USER}@${RSYNC_HOST} df -P ${RSYNC_PATH} 2>/dev/null | tail -1 | awk '{print $5}' | sed -e 's/%//')
5d051d
+	echo $(ssh $(rsync_remote_ssh "$BACKUP_URL") df -P ${path} 2>/dev/null | tail -1 | awk '{print $5}' | sed -e 's/%//')
5d051d
 }
5d051d
 
5d051d
 check_remote_du() {
5d051d
-	x=$(ssh ${RSYNC_USER}@${RSYNC_HOST} du -sb ${RSYNC_PATH}/${RSYNC_PREFIX}/backup 2>/dev/null | awk '{print $1}')
5d051d
+	x=$(ssh $(rsync_remote_ssh "$BACKUP_URL") du -sb $(rsync_path_full "$BACKUP_URL")/backup 2>/dev/null | awk '{print $1}')
5d051d
 	[[ -z "${x}" ]] && x=0
5d051d
 	echo $x
5d051d
 }
5d051d
@@ -81,7 +87,7 @@ case "$(basename $BACKUP_PROG)" in
5d051d
 			case $i in
5d051d
 
5d051d
 			300)
5d051d
-			[[ $(check_remote_df) -eq 100 ]] && Error "Disk is full on system ${RSYNC_HOST}"
5d051d
+			[[ $(check_remote_df) -eq 100 ]] && Error "Disk is full on system ${host}"
5d051d
 			;;
5d051d
 
5d051d
 			15|30|45|60|75|90|105|120|135|150|165|180|195|210|225|240|255|270|285)
5d051d
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
5d051d
index b90d459b..76b9f971 100644
5d051d
--- a/usr/share/rear/backup/RSYNC/default/700_copy_backup_log.sh
5d051d
+++ b/usr/share/rear/backup/RSYNC/default/700_copy_backup_log.sh
5d051d
@@ -1,26 +1,27 @@
5d051d
 
5d051d
 # copy the backup.log & rear.log file to remote destination with timestamp added
5d051d
-local timestamp
5d051d
+local timestamp proto
5d051d
 
5d051d
 timestamp=$( date +%Y%m%d.%H%M )
5d051d
+proto="$(rsync_proto "$BACKUP_URL")"
5d051d
 
5d051d
 # compress the log file first
5d051d
 gzip "$TMP_DIR/$BACKUP_PROG_ARCHIVE.log" || Error "Failed to 'gzip $TMP_DIR/$BACKUP_PROG_ARCHIVE.log'"
5d051d
 
5d051d
-case $RSYNC_PROTO in
5d051d
+case $proto in
5d051d
     (ssh)
5d051d
         # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
5d051d
         # or remove it according to https://github.com/rear/rear/issues/1395
5d051d
         $BACKUP_PROG -a "${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log.gz" \
5d051d
-        "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/${BACKUP_PROG_ARCHIVE}-${timestamp}.log.gz" 2>/dev/null
5d051d
+        "$(rsync_remote_full "$BACKUP_URL")/${BACKUP_PROG_ARCHIVE}-${timestamp}.log.gz" 2>/dev/null
5d051d
 
5d051d
-        $BACKUP_PROG -a "$RUNTIME_LOGFILE" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/rear-${timestamp}.log" 2>/dev/null
5d051d
+        $BACKUP_PROG -a "$RUNTIME_LOGFILE" "$(rsync_remote_full "$BACKUP_URL")/rear-${timestamp}.log" 2>/dev/null
5d051d
         ;;
5d051d
     (rsync)
5d051d
         $BACKUP_PROG -a "${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log.gz" "${BACKUP_RSYNC_OPTIONS[@]}" \
5d051d
-        "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/${BACKUP_PROG_ARCHIVE}-${timestamp}.log.gz"
5d051d
+        "$(rsync_remote_full "$BACKUP_URL")/${BACKUP_PROG_ARCHIVE}-${timestamp}.log.gz"
5d051d
 
5d051d
-        $BACKUP_PROG -a "$RUNTIME_LOGFILE" "${BACKUP_RSYNC_OPTIONS[@]}" "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}//rear-${timestamp}.log"
5d051d
+        $BACKUP_PROG -a "$RUNTIME_LOGFILE" "${BACKUP_RSYNC_OPTIONS[@]}" "$(rsync_remote_full "$BACKUP_URL")//rear-${timestamp}.log"
5d051d
         ;;
5d051d
 esac
5d051d
 
5d051d
diff --git a/usr/share/rear/lib/global-functions.sh b/usr/share/rear/lib/global-functions.sh
5d051d
index 32aeb8ca..2edb64a6 100644
5d051d
--- a/usr/share/rear/lib/global-functions.sh
5d051d
+++ b/usr/share/rear/lib/global-functions.sh
5d051d
@@ -259,7 +259,7 @@ function url_scheme() {
5d051d
     # the scheme is the leading part up to '://'
5d051d
     local scheme=${url%%://*}
5d051d
     # rsync scheme does not have to start with rsync:// it can also be scp style
5d051d
-    # see the comments in usr/share/rear/prep/RSYNC/default/100_check_rsync.sh
5d051d
+    # see the comments in usr/share/rear/lib/rsync-functions.sh
5d051d
     echo $scheme | grep -q ":" && echo rsync || echo $scheme
5d051d
 }
5d051d
 
5d051d
diff --git a/usr/share/rear/lib/rsync-functions.sh b/usr/share/rear/lib/rsync-functions.sh
5d051d
new file mode 100644
5d051d
index 00000000..443a9625
5d051d
--- /dev/null
5d051d
+++ b/usr/share/rear/lib/rsync-functions.sh
5d051d
@@ -0,0 +1,178 @@
5d051d
+# Functions for manipulation of rsync URLs (both OUTPUT_URL and BACKUP_URL)
5d051d
+
5d051d
+#### OLD STYLE:
5d051d
+# BACKUP_URL=[USER@]HOST:PATH           # using ssh (no rsh)
5d051d
+#
5d051d
+# with rsync protocol PATH is a MODULE name defined in remote /etc/rsyncd.conf file
5d051d
+# BACKUP_URL=[USER@]HOST::PATH          # using rsync
5d051d
+# BACKUP_URL=rsync://[USER@]HOST[:PORT]/PATH    # using rsync (is not compatible with new style!!!)
5d051d
+
5d051d
+#### NEW STYLE:
5d051d
+# BACKUP_URL=rsync://[USER@]HOST[:PORT]/PATH    # using ssh
5d051d
+# BACKUP_URL=rsync://[USER@]HOST[:PORT]::/PATH  # using rsync
5d051d
+
5d051d
+function rsync_validate () {
5d051d
+    local url="$1"
5d051d
+
5d051d
+    if [[ "$(url_scheme "$url")" != "rsync" ]]; then # url_scheme still recognizes old style
5d051d
+        BugError "Non-rsync URL $url !"
5d051d
+    fi
5d051d
+}
5d051d
+
5d051d
+# Determine whether the URL specifies the use of the rsync protocol (rsyncd) or ssh
5d051d
+# Do not call on non-rsync URLs (use url_scheme first)
5d051d
+function rsync_proto () {
5d051d
+    local url="$1"
5d051d
+
5d051d
+    rsync_validate "$url"
5d051d
+    if egrep -q '(::)' <<< $url ; then # new style '::' means rsync protocol
5d051d
+        echo rsync
5d051d
+    else
5d051d
+        echo ssh
5d051d
+    fi
5d051d
+}
5d051d
+
5d051d
+# Functions to parse the URL into its components:
5d051d
+# USER, HOST, PORT, PATH
5d051d
+
5d051d
+function rsync_user () {
5d051d
+    local url="$1"
5d051d
+    local host
5d051d
+
5d051d
+    host=$(url_host "$url")
5d051d
+
5d051d
+    if grep -q '@' <<< $host ; then
5d051d
+        echo "${host%%@*}"    # grab user name
5d051d
+    else
5d051d
+        echo root
5d051d
+    fi
5d051d
+}
5d051d
+
5d051d
+function rsync_host () {
5d051d
+    local url="$1"
5d051d
+    local host
5d051d
+    local path
5d051d
+
5d051d
+    host=$(url_host "$url")
5d051d
+    path=$(url_path "$url")
5d051d
+    # remove USER@ if present
5d051d
+    local tmp2="${host#*@}"
5d051d
+
5d051d
+    case "$(rsync_proto "$url")" in
5d051d
+        (rsync)
5d051d
+            # tmp2=witsbebelnx02::backup or tmp2=witsbebelnx02::
5d051d
+            echo "${tmp2%%::*}"
5d051d
+            ;;
5d051d
+        (ssh)
5d051d
+            # tmp2=host or tmp2=host:
5d051d
+            echo "${tmp2%%:*}"
5d051d
+            ;;
5d051d
+    esac
5d051d
+}
5d051d
+
5d051d
+function rsync_path () {
5d051d
+    local url="$1"
5d051d
+    local host
5d051d
+    local path
5d051d
+    local url_without_scheme
5d051d
+    local url_without_scheme_user
5d051d
+
5d051d
+    host=$(url_host "$url")
5d051d
+    path=$(url_path "$url")
5d051d
+    local tmp2="${host#*@}"
5d051d
+
5d051d
+    url_without_scheme="${url#*//}"
5d051d
+    url_without_scheme_user="${url_without_scheme#$(rsync_user "$url")@}"
5d051d
+
5d051d
+    case "$(rsync_proto "$url")" in
5d051d
+
5d051d
+        (rsync)
5d051d
+            if grep -q '::' <<< $url_without_scheme_user ; then
5d051d
+                # we can not use url_path here, it uses / as separator, not ::
5d051d
+                local url_after_separator="${url_without_scheme_user##*::}"
5d051d
+                # remove leading / - this is a module name
5d051d
+                echo "${url_after_separator#/}"
5d051d
+            else
5d051d
+                echo "${path#*/}"
5d051d
+            fi
5d051d
+            ;;
5d051d
+        (ssh)
5d051d
+            if [ "$url_without_scheme" == "$url" ]; then
5d051d
+                # no scheme - old-style URL
5d051d
+                if grep -q ':' <<< $url_without_scheme_user ; then
5d051d
+                    echo "${url_without_scheme_user##*:}"
5d051d
+                else
5d051d
+                    BugError "Old-style rsync URL $url without : !"
5d051d
+                fi
5d051d
+            else
5d051d
+                echo "$path"
5d051d
+            fi
5d051d
+            ;;
5d051d
+
5d051d
+    esac
5d051d
+}
5d051d
+
5d051d
+function rsync_port () {
5d051d
+    # XXX changing port not implemented yet
5d051d
+    echo 873
5d051d
+}
5d051d
+
5d051d
+# Full path to the destination directory on the remote server,
5d051d
+# includes RSYNC_PREFIX. RSYNC_PREFIX is not given by the URL,
5d051d
+# it is a global parameter (by default derived from hostname).
5d051d
+function rsync_path_full () {
5d051d
+    local url="$1"
5d051d
+
5d051d
+    echo "$(rsync_path "$url")/${RSYNC_PREFIX}"
5d051d
+}
5d051d
+
5d051d
+# Argument for the ssh command to log in to the remote host ("user@host")
5d051d
+function rsync_remote_ssh () {
5d051d
+    local url="$1"
5d051d
+
5d051d
+    local user host
5d051d
+
5d051d
+    user="$(rsync_user "$url")"
5d051d
+    host="$(rsync_host "$url")"
5d051d
+
5d051d
+    echo "${user}@${host}"
5d051d
+}
5d051d
+
5d051d
+# Argument for the rsync command to reach the remote host, without path.
5d051d
+function rsync_remote_base () {
5d051d
+    local url="$1"
5d051d
+
5d051d
+    local user host port
5d051d
+
5d051d
+    user="$(rsync_user "$url")"
5d051d
+    host="$(rsync_host "$url")"
5d051d
+    port="$(rsync_port "$url")"
5d051d
+
5d051d
+    case "$(rsync_proto "$url")" in
5d051d
+
5d051d
+        (rsync)
5d051d
+            echo "rsync://${user}@${host}:${port}/"
5d051d
+            ;;
5d051d
+        (ssh)
5d051d
+            echo "$(rsync_remote_ssh "$url"):"
5d051d
+            ;;
5d051d
+
5d051d
+    esac
5d051d
+}
5d051d
+
5d051d
+# Complete argument to rsync to reach the remote location identified by URL,
5d051d
+# but without the added RSYNC_PREFIX.
5d051d
+# This essentially converts our rsync:// URLs into a form accepted by the rsync command.
5d051d
+function rsync_remote () {
5d051d
+    local url="$1"
5d051d
+
5d051d
+    echo "$(rsync_remote_base "$url")$(rsync_path "$url")"
5d051d
+}
5d051d
+
5d051d
+# Complete argument to rsync including even RSYNC_PREFIX.
5d051d
+# Determined from the URL and RSYNC_PREFIX.
5d051d
+function rsync_remote_full () {
5d051d
+    local url="$1"
5d051d
+
5d051d
+    echo "$(rsync_remote_base "$url")$(rsync_path_full "$url")"
5d051d
+}
5d051d
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
5d051d
index 519febf5..d00d15e4 100644
5d051d
--- a/usr/share/rear/output/RSYNC/default/200_make_prefix_dir.sh
5d051d
+++ b/usr/share/rear/output/RSYNC/default/200_make_prefix_dir.sh
5d051d
@@ -1,20 +1,32 @@
5d051d
 # Create RSYNC_PREFIX under the local TMP_DIR and also on remote rsync server
5d051d
 # RSYNC_PREFIX=$HOSTNAME as set in default.conf
5d051d
 
5d051d
-# create temporary local work-spaces to collect files (we already make the remote backup dir with the correct mode!!)
5d051d
+local proto host scheme
5d051d
+
5d051d
+scheme="$(url_scheme "$OUTPUT_URL")"
5d051d
+
5d051d
+# we handle only rsync:// output schemes.
5d051d
+# ToDo: why does handling of the output URL scheme belong under RSYNC (which is a backup method)?
5d051d
+# OUTPUT_URL is independent on the chosen backup method, so this code should be moved to be backup-independent.
5d051d
+test "rsync" = "$scheme" || return 0
5d051d
+
5d051d
+proto="$(rsync_proto "$OUTPUT_URL")"
5d051d
+host="$(rsync_host "$OUTPUT_URL")"
5d051d
+
5d051d
+# create temporary local work-spaces to collect files
5d051d
 mkdir -p $v -m0750 "${TMP_DIR}/rsync/${RSYNC_PREFIX}" >&2 || Error "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}'"
5d051d
-mkdir -p $v -m0755 "${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup" >&2 || Error "Could not mkdir '${TMP_DIR}/rsync/${RSYNC_PREFIX}/backup'"
5d051d
 
5d051d
-case $RSYNC_PROTO in
5d051d
+case $proto in
5d051d
 
5d051d
 	(ssh)
5d051d
-		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}" >/dev/null 2>&1 \
5d051d
-                    || Error "Could not create '${RSYNC_PATH}/${RSYNC_PREFIX}' on remote ${RSYNC_HOST}"
5d051d
+		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "$(rsync_remote "$OUTPUT_URL")" >/dev/null 2>&1 \
5d051d
+                    || Error "Could not create '$(rsync_path_full "$OUTPUT_URL")' on remote ${host}"
5d051d
 		;;
5d051d
 
5d051d
 	(rsync)
5d051d
-		$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 \
5d051d
-                    || Error "Could not create '${RSYNC_PATH}/${RSYNC_PREFIX}' on remote ${RSYNC_HOST}"
5d051d
+		# This must run before the backup stage. Otherwise --relative gets added to BACKUP_RSYNC_OPTIONS
5d051d
+		$BACKUP_PROG -a $v -r "${TMP_DIR}/rsync/${RSYNC_PREFIX}" "${BACKUP_RSYNC_OPTIONS[@]}" "$(rsync_remote "$OUTPUT_URL")/" >/dev/null \
5d051d
+                    || Error "Could not create '$(rsync_path_full "$OUTPUT_URL")' on remote ${host}"
5d051d
 		;;
5d051d
 
5d051d
 esac
5d051d
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
5d051d
index 96b62da1..4ddf3cb4 100644
5d051d
--- a/usr/share/rear/output/RSYNC/default/900_copy_result_files.sh
5d051d
+++ b/usr/share/rear/output/RSYNC/default/900_copy_result_files.sh
5d051d
@@ -1,6 +1,17 @@
5d051d
 #
5d051d
 # copy resulting files to remote network (backup) location
5d051d
 
5d051d
+local proto scheme
5d051d
+
5d051d
+scheme="$(url_scheme "$OUTPUT_URL")"
5d051d
+
5d051d
+# we handle only rsync:// output schemes.
5d051d
+# ToDo: why does handling of the output URL scheme belong under RSYNC (which is a backup method)?
5d051d
+# OUTPUT_URL is independent on the chosen backup method, so this code should be moved to be backup-independent.
5d051d
+test "rsync" = "$scheme" || return 0
5d051d
+
5d051d
+proto="$(rsync_proto "$OUTPUT_URL")"
5d051d
+
5d051d
 LogPrint "Copying resulting files to $OUTPUT_URL location"
5d051d
 
5d051d
 # if called as mkbackuponly then we just don't have any result files.
5d051d
@@ -19,21 +30,21 @@ cp $v $(get_template "RESULT_usage_$OUTPUT.txt") "${TMP_DIR}/rsync/${RSYNC_PREFI
5d051d
 cat "$RUNTIME_LOGFILE" >"${TMP_DIR}/rsync/${RSYNC_PREFIX}/rear.log" \
5d051d
     || Error "Could not copy $RUNTIME_LOGFILE to local rsync location"
5d051d
 
5d051d
-case $RSYNC_PROTO in
5d051d
+case $proto in
5d051d
 
5d051d
     (ssh)
5d051d
-    Log "$BACKUP_PROG -a ${TMP_DIR}/rsync/${RSYNC_PREFIX}/ ${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/"
5d051d
+    Log "$BACKUP_PROG -a ${TMP_DIR}/rsync/${RSYNC_PREFIX}/ $(rsync_remote_full "$OUTPUT_URL")/"
5d051d
     # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
5d051d
     # or remove it according to https://github.com/rear/rear/issues/1395
5d051d
-    $BACKUP_PROG -a "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/" 2>/dev/null \
5d051d
+    $BACKUP_PROG -a "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" "$(rsync_remote_full "$OUTPUT_URL")/" 2>/dev/null \
5d051d
         || Error "Could not copy '${RESULT_FILES[*]}' to $OUTPUT_URL location"
5d051d
     ;;
5d051d
 
5d051d
     (rsync)
5d051d
-    Log "$BACKUP_PROG -a ${TMP_DIR}/rsync/${RSYNC_PREFIX}/ ${BACKUP_RSYNC_OPTIONS[*]} ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/"
5d051d
+    Log "$BACKUP_PROG -a ${TMP_DIR}/rsync/${RSYNC_PREFIX}/ ${BACKUP_RSYNC_OPTIONS[*]} $(rsync_remote_full "$OUTPUT_URL")/"
5d051d
     # FIXME: Add an explanatory comment why "2>/dev/null" is useful here
5d051d
     # or remove it according to https://github.com/rear/rear/issues/1395
5d051d
-    $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 \
5d051d
+    $BACKUP_PROG -a "${TMP_DIR}/rsync/${RSYNC_PREFIX}/" "${BACKUP_RSYNC_OPTIONS[@]}" "$(rsync_remote_full "$OUTPUT_URL")/" 2>/dev/null \
5d051d
         || Error "Could not copy '${RESULT_FILES[*]}' to $OUTPUT_URL location"
5d051d
     ;;
5d051d
 
5d051d
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
5d051d
index eb7df29e..84500039 100644
5d051d
--- a/usr/share/rear/prep/RSYNC/GNU/Linux/200_selinux_in_use.sh
5d051d
+++ b/usr/share/rear/prep/RSYNC/GNU/Linux/200_selinux_in_use.sh
5d051d
@@ -25,8 +25,10 @@ case $(basename $BACKUP_PROG) in
5d051d
 
5d051d
 	(rsync)
5d051d
 		if grep -q "no xattrs" "$TMP_DIR/rsync_protocol"; then
5d051d
+			local host
5d051d
+			host="$(rsync_host "$BACKUP_URL")"
5d051d
 			# no xattrs compiled in remote rsync, so saving SELinux attributes are not possible
5d051d
-			Log "WARNING: --xattrs not possible on system ($RSYNC_HOST) (no xattrs compiled in rsync)"
5d051d
+			Log "WARNING: --xattrs not possible on system ($host) (no xattrs compiled in rsync)"
5d051d
 			# $TMP_DIR/selinux.mode is a trigger during backup to disable SELinux
5d051d
 			cat $SELINUX_ENFORCE > $TMP_DIR/selinux.mode
5d051d
 			RSYNC_SELINUX=		# internal variable used in recover mode (empty means disable SELinux)
5d051d
diff --git a/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh b/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh
5d051d
index c964a148..448a1b1a 100644
5d051d
--- a/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh
5d051d
+++ b/usr/share/rear/prep/RSYNC/default/100_check_rsync.sh
5d051d
@@ -3,97 +3,40 @@
5d051d
 # This file is part of Relax-and-Recover, licensed under the GNU General
5d051d
 # Public License. Refer to the included COPYING for full text of license.
5d051d
 
5d051d
-#### OLD STYLE:
5d051d
-# BACKUP_URL=[USER@]HOST:PATH           # using ssh (no rsh)
5d051d
-#
5d051d
-# with rsync protocol PATH is a MODULE name defined in remote /etc/rsyncd.conf file
5d051d
-# BACKUP_URL=[USER@]HOST::PATH          # using rsync
5d051d
-# BACKUP_URL=rsync://[USER@]HOST[:PORT]/PATH    # using rsync (is not compatible with new style!!!)
5d051d
-
5d051d
-#### NEW STYLE:
5d051d
-# BACKUP_URL=rsync://[USER@]HOST[:PORT]/PATH    # using ssh
5d051d
-# BACKUP_URL=rsync://[USER@]HOST[:PORT]::/PATH  # using rsync
5d051d
-
5d051d
 if test -z "$BACKUP_URL" ; then
5d051d
     Error "Missing BACKUP_URL=rsync://[USER@]HOST[:PORT][::]/PATH !"
5d051d
 fi
5d051d
 
5d051d
-local host=$(url_host $BACKUP_URL)
5d051d
 local scheme=$(url_scheme $BACKUP_URL)  # url_scheme still recognizes old style
5d051d
-local path=$(url_path $BACKUP_URL)
5d051d
 
5d051d
 if [[ "$scheme" != "rsync" ]]; then
5d051d
     Error "Missing BACKUP_URL=rsync://[USER@]HOST[:PORT][::]/PATH !"
5d051d
 fi
5d051d
 
5d051d
-RSYNC_PROTO=                    # ssh or rsync
5d051d
-RSYNC_USER=
5d051d
-RSYNC_HOST=
5d051d
-RSYNC_PORT=873                  # default port (of rsync server)
5d051d
-RSYNC_PATH=
5d051d
-
5d051d
-
5d051d
-if egrep -q '(::)' <<< $BACKUP_URL ; then # new style '::' means rsync protocol
5d051d
-    RSYNC_PROTO=rsync
5d051d
-else
5d051d
-    RSYNC_PROTO=ssh
5d051d
-fi
5d051d
-
5d051d
-if grep -q '@' <<< $host ; then
5d051d
-    RSYNC_USER="${host%%@*}"    # grab user name
5d051d
-else
5d051d
-    RSYNC_USER=root
5d051d
-fi
5d051d
-
5d051d
-# remove USER@ if present (we don't need it anymore)
5d051d
-local tmp2="${host#*@}"
5d051d
-
5d051d
-case "$RSYNC_PROTO" in
5d051d
-
5d051d
-    (rsync)
5d051d
-        # tmp2=witsbebelnx02::backup or tmp2=witsbebelnx02::
5d051d
-        RSYNC_HOST="${tmp2%%::*}"
5d051d
-        # path=/gdhaese1@witsbebelnx02::backup or path=/backup
5d051d
-        if grep -q '::' <<< $path ; then
5d051d
-            RSYNC_PATH="${path##*::}"
5d051d
-        else
5d051d
-            RSYNC_PATH="${path##*/}"
5d051d
-        fi
5d051d
-        ;;
5d051d
-    (ssh)
5d051d
-        # tmp2=host or tmp2=host:
5d051d
-        RSYNC_HOST="${tmp2%%:*}"
5d051d
-        RSYNC_PATH=$path
5d051d
-        ;;
5d051d
-
5d051d
-esac
5d051d
-
5d051d
-#echo RSYNC_PROTO=$RSYNC_PROTO
5d051d
-#echo RSYNC_USER=$RSYNC_USER
5d051d
-#echo RSYNC_HOST=$RSYNC_HOST
5d051d
-#echo RSYNC_PORT=$RSYNC_PORT
5d051d
-#echo RSYNC_PATH=$RSYNC_PATH
5d051d
+local host proto
5d051d
+host="$(rsync_host "$BACKUP_URL")"
5d051d
+proto="$(rsync_proto "$BACKUP_URL")"
5d051d
 
5d051d
 # check if host is reachable
5d051d
 if test "$PING" ; then
5d051d
-    ping -c 2 "$RSYNC_HOST" >/dev/null || Error "Backup host [$RSYNC_HOST] not reachable."
5d051d
+    ping -c 2 "$host" >/dev/null || Error "Backup host [$host] not reachable."
5d051d
 else
5d051d
     Log "Skipping ping test"
5d051d
 fi
5d051d
 
5d051d
 # check protocol connectivity
5d051d
-case "$RSYNC_PROTO" in
5d051d
+case "$proto" in
5d051d
 
5d051d
     (rsync)
5d051d
-        Log "Test: $BACKUP_PROG ${BACKUP_RSYNC_OPTIONS[*]} ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/"
5d051d
-        $BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" ${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/ >/dev/null \
5d051d
-            || Error "Rsync daemon not running on $RSYNC_HOST"
5d051d
+        Log "Test: $BACKUP_PROG ${BACKUP_RSYNC_OPTIONS[*]} $(rsync_remote_base "$BACKUP_URL")"
5d051d
+        $BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" $(rsync_remote_base "$BACKUP_URL") >/dev/null \
5d051d
+            || Error "Rsync daemon not running on $host"
5d051d
         ;;
5d051d
 
5d051d
     (ssh)
5d051d
-        Log "Test: ssh ${RSYNC_USER}@${RSYNC_HOST} /bin/true"
5d051d
-        ssh ${RSYNC_USER}@${RSYNC_HOST} /bin/true >/dev/null 2>&1 \
5d051d
-            || Error "Secure shell connection not setup properly [$RSYNC_USER@$RSYNC_HOST]"
5d051d
+        Log "Test: ssh $(rsync_remote_ssh "$BACKUP_URL") /bin/true"
5d051d
+        ssh $(rsync_remote_ssh "$BACKUP_URL") /bin/true >/dev/null 2>&1 \
5d051d
+            || Error "Secure shell connection not setup properly [$(rsync_remote_ssh "$BACKUP_URL")]"
5d051d
         ;;
5d051d
 
5d051d
 esac
5d051d
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
5d051d
index e9103531..becf35a0 100644
5d051d
--- a/usr/share/rear/prep/RSYNC/default/150_check_rsync_protocol_version.sh
5d051d
+++ b/usr/share/rear/prep/RSYNC/default/150_check_rsync_protocol_version.sh
5d051d
@@ -3,15 +3,18 @@
5d051d
 # Public License. Refer to the included COPYING for full text of license.
5d051d
 # try to grab the rsync protocol version of rsync on the remote server
5d051d
 
5d051d
-local remote_mountpoint
5d051d
+local remote_mountpoint host path proto
5d051d
+host="$(rsync_host "$BACKUP_URL")"
5d051d
+path="$(rsync_path "$BACKUP_URL")"
5d051d
+proto="$(rsync_proto "$BACKUP_URL")"
5d051d
 
5d051d
 if [ -z "$RSYNC_PROTOCOL_VERSION" ]; then
5d051d
 
5d051d
-    case $RSYNC_PROTO in
5d051d
+    case $proto in
5d051d
 
5d051d
     (ssh)
5d051d
-        ssh ${RSYNC_USER}@${RSYNC_HOST} rsync --version >"$TMP_DIR/rsync_protocol" 2>&1 \
5d051d
-            || Error "Secure shell connection not setup properly [$RSYNC_USER@$RSYNC_HOST]"
5d051d
+        ssh $(rsync_remote_ssh "$BACKUP_URL") rsync --version >"$TMP_DIR/rsync_protocol" 2>&1 \
5d051d
+            || Error "Secure shell connection not setup properly [$(rsync_remote_ssh "$BACKUP_URL")]"
5d051d
         if grep -q "protocol version" "$TMP_DIR/rsync_protocol" ; then
5d051d
             RSYNC_PROTOCOL_VERSION=$(grep 'protocol version' "$TMP_DIR/rsync_protocol" | awk '{print $6}')
5d051d
         else
5d051d
@@ -24,29 +27,29 @@ if [ -z "$RSYNC_PROTOCOL_VERSION" ]; then
5d051d
         RSYNC_PROTOCOL_VERSION=29 # being conservative (old rsync)
5d051d
         ;;
5d051d
     esac
5d051d
-    Log "Remote rsync system ($RSYNC_HOST) uses rsync protocol version $RSYNC_PROTOCOL_VERSION"
5d051d
+    Log "Remote rsync system ($host) uses rsync protocol version $RSYNC_PROTOCOL_VERSION"
5d051d
 
5d051d
 else
5d051d
 
5d051d
-    Log "Remote rsync system ($RSYNC_HOST) uses rsync protocol version $RSYNC_PROTOCOL_VERSION (overruled by user)"
5d051d
+    Log "Remote rsync system ($host) uses rsync protocol version $RSYNC_PROTOCOL_VERSION (overruled by user)"
5d051d
 
5d051d
 fi
5d051d
 
5d051d
-if [ "${RSYNC_USER}" != "root" -a $RSYNC_PROTO = "ssh" ]; then
5d051d
+if [ "$(rsync_user "$BACKUP_URL")" != "root" -a $proto = "ssh" ]; then
5d051d
     if [ $RSYNC_PROTOCOL_VERSION -gt 29 ]; then
5d051d
         if grep -q "no xattrs" "$TMP_DIR/rsync_protocol"; then
5d051d
             # no xattrs available in remote rsync, so --fake-super is not possible
5d051d
-            Error "rsync --fake-super not possible on system ($RSYNC_HOST) (no xattrs compiled in rsync)"
5d051d
+            Error "rsync --fake-super not possible on system ($host) (no xattrs compiled in rsync)"
5d051d
         else
5d051d
             # when using --fake-super we must have user_xattr mount options on the remote mntpt
5d051d
-            remote_mountpoint=$(ssh ${RSYNC_USER}@${RSYNC_HOST} 'cd ${RSYNC_PATH}; df -P .' 2>/dev/null | tail -1 | awk '{print $6}')
5d051d
-            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" \
5d051d
+            remote_mountpoint=$(ssh $(rsync_remote_ssh "$BACKUP_URL") 'cd ${path}; df -P .' 2>/dev/null | tail -1 | awk '{print $6}')
5d051d
+            ssh $(rsync_remote_ssh "$BACKUP_URL") "cd ${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" \
5d051d
                 || Error "Remote file system $remote_mountpoint does not have user_xattr mount option set!"
5d051d
             #BACKUP_RSYNC_OPTIONS+=( --xattrs --rsync-path="rsync --fake-super" )
5d051d
             # see issue #366 for explanation of removing --xattrs
5d051d
             BACKUP_RSYNC_OPTIONS+=( --rsync-path="rsync --fake-super" )
5d051d
         fi
5d051d
     else
5d051d
-        Error "rsync --fake-super not possible on system ($RSYNC_HOST) (please upgrade rsync to 3.x)"
5d051d
+        Error "rsync --fake-super not possible on system ($host) (please upgrade rsync to 3.x)"
5d051d
     fi
5d051d
 fi
5d051d
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
5d051d
index 993088be..0fa08587 100644
5d051d
--- a/usr/share/rear/restore/RSYNC/default/400_restore_rsync_backup.sh
5d051d
+++ b/usr/share/rear/restore/RSYNC/default/400_restore_rsync_backup.sh
5d051d
@@ -7,7 +7,11 @@ get_size() {
5d051d
 local backup_prog_rc
5d051d
 local restore_log_message
5d051d
 
5d051d
-LogPrint "Restoring $BACKUP_PROG backup from '${RSYNC_HOST}:${RSYNC_PATH}'"
5d051d
+local host path
5d051d
+host="$(rsync_host "$BACKUP_URL")"
5d051d
+path="$(rsync_path "$BACKUP_URL")"
5d051d
+
5d051d
+LogPrint "Restoring $BACKUP_PROG backup from '${host}:${path}'"
5d051d
 
5d051d
 ProgressStart "Restore operation"
5d051d
 (
5d051d
@@ -15,18 +19,18 @@ ProgressStart "Restore operation"
5d051d
 
5d051d
 		(rsync)
5d051d
 
5d051d
-			case $RSYNC_PROTO in
5d051d
+			case $(rsync_proto "$BACKUP_URL") in
5d051d
 
5d051d
 				(ssh)
5d051d
-					Log $BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" "${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/backup"/ $TARGET_FS_ROOT/
5d051d
+					Log $BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" "$(rsync_remote_full "$BACKUP_URL")/backup"/ $TARGET_FS_ROOT/
5d051d
 					$BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" \
5d051d
-					"${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PATH}/${RSYNC_PREFIX}/backup"/ \
5d051d
+					"$(rsync_remote_full "$BACKUP_URL")/backup"/ \
5d051d
 					$TARGET_FS_ROOT/
5d051d
 					;;
5d051d
 
5d051d
 				(rsync)
5d051d
 					$BACKUP_PROG "${BACKUP_RSYNC_OPTIONS[@]}" \
5d051d
-					"${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup"/ $TARGET_FS_ROOT/
5d051d
+					"$(rsync_remote_full "$BACKUP_URL")/backup"/ $TARGET_FS_ROOT/
5d051d
 					;;
5d051d
 
5d051d
 			esac
5d051d
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
5d051d
index b2fb72f5..76132794 100644
5d051d
--- a/usr/share/rear/verify/RSYNC/default/550_check_remote_backup_archive.sh
5d051d
+++ b/usr/share/rear/verify/RSYNC/default/550_check_remote_backup_archive.sh
5d051d
@@ -1,14 +1,14 @@
5d051d
 # check the backup archive on remote rsync server
5d051d
 
5d051d
-case $RSYNC_PROTO in
5d051d
+case $(rsync_proto "$BACKUP_URL") in
5d051d
 
5d051d
 	(ssh)
5d051d
-		ssh ${RSYNC_USER}@${RSYNC_HOST} "ls -ld ${RSYNC_PATH}/${RSYNC_PREFIX}/backup" >/dev/null 2>&1 \
5d051d
-		    || Error "Archive not found on [$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}]"
5d051d
+		ssh $(rsync_remote_ssh "$BACKUP_URL") "ls -ld $(rsync_path_full "$BACKUP_URL")/backup" >/dev/null 2>&1 \
5d051d
+		    || Error "Archive not found on [$(rsync_remote_full "$BACKUP_URL")]"
5d051d
 		;;
5d051d
 
5d051d
 	(rsync)
5d051d
-		$BACKUP_PROG "${RSYNC_PROTO}://${RSYNC_USER}@${RSYNC_HOST}:${RSYNC_PORT}/${RSYNC_PATH}/${RSYNC_PREFIX}/backup" >/dev/null 2>&1 \
5d051d
-		    || Error "Archive not found on [$RSYNC_USER@$RSYNC_HOST:${RSYNC_PATH}/${RSYNC_PREFIX}]"
5d051d
+		$BACKUP_PROG "$(rsync_remote_full "$BACKUP_URL")/backup" >/dev/null 2>&1 \
5d051d
+		    || Error "Archive not found on [$(rsync_remote_full "$BACKUP_URL")]"
5d051d
 		;;
5d051d
 esac