Blame SOURCES/rear-bz1958247.patch

6f74ef
diff --git a/usr/share/rear/backup/DUPLICITY/default/100_mount_duplicity_path.sh b/usr/share/rear/backup/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
index 64b7a792..6ba7d543 100644
6f74ef
--- a/usr/share/rear/backup/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
+++ b/usr/share/rear/backup/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
@@ -1,10 +1,4 @@
6f74ef
-# create mount point
6f74ef
 if [ -n "$BACKUP_DUPLICITY_NETFS_URL" -o -n "$BACKUP_DUPLICITY_NETFS_MOUNTCMD" ]; then
6f74ef
-	mkdir -p $v "$BUILD_DIR/outputfs" >&2
6f74ef
-	StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"
6f74ef
-
6f74ef
-	AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-
6f74ef
 	if [[ "$BACKUP_DUPLICITY_NETFS_MOUNTCMD" ]] ; then
6f74ef
 		BACKUP_DUPLICITY_NETFS_URL="var://BACKUP_DUPLICITY_NETFS_MOUNTCMD"
6f74ef
 	fi
6f74ef
diff --git a/usr/share/rear/backup/DUPLICITY/default/980_unmount_duplicity_path.sh b/usr/share/rear/backup/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
index 185dbd95..8525ab1d 100644
6f74ef
--- a/usr/share/rear/backup/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
+++ b/usr/share/rear/backup/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
@@ -6,10 +6,4 @@ if [  -n "$BACKUP_DUPLICITY_NETFS_URL" -o -n "$BACKUP_DUPLICITY_NETFS_UMOUNTCMD"
6f74ef
 	fi
6f74ef
 
6f74ef
 	umount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs
6f74ef
-
6f74ef
-	rmdir $v $BUILD_DIR/outputfs >&2
6f74ef
-	if [[ $? -eq 0 ]] ; then
6f74ef
-		# the argument to RemoveExitTask has to be identical to the one given to AddExitTask
6f74ef
-		RemoveExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-	fi
6f74ef
 fi
6f74ef
diff --git a/usr/share/rear/backup/NETFS/default/100_mount_NETFS_path.sh b/usr/share/rear/backup/NETFS/default/100_mount_NETFS_path.sh
6f74ef
index 5c7696db..b6a955db 100644
6f74ef
--- a/usr/share/rear/backup/NETFS/default/100_mount_NETFS_path.sh
6f74ef
+++ b/usr/share/rear/backup/NETFS/default/100_mount_NETFS_path.sh
6f74ef
@@ -1,9 +1,3 @@
6f74ef
-# create mount point
6f74ef
-mkdir -p $v "$BUILD_DIR/outputfs" >&2
6f74ef
-StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"
6f74ef
-
6f74ef
-AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-
6f74ef
 if [[ "$BACKUP_MOUNTCMD" ]] ; then
6f74ef
     BACKUP_URL="var://BACKUP_MOUNTCMD"
6f74ef
 fi
6f74ef
diff --git a/usr/share/rear/backup/NETFS/default/150_save_copy_of_prefix_dir.sh b/usr/share/rear/backup/NETFS/default/150_save_copy_of_prefix_dir.sh
6f74ef
index d79653b4..9bf8f76a 100644
6f74ef
--- a/usr/share/rear/backup/NETFS/default/150_save_copy_of_prefix_dir.sh
6f74ef
+++ b/usr/share/rear/backup/NETFS/default/150_save_copy_of_prefix_dir.sh
6f74ef
@@ -3,20 +3,17 @@
6f74ef
 [ -z "${NETFS_KEEP_OLD_BACKUP_COPY}" ] && return
6f74ef
 
6f74ef
 # do not do this for tapes and special attention for file:///path
6f74ef
-url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
6f74ef
-local scheme=$(url_scheme ${!url})
6f74ef
-local path=$(url_path ${!url})
6f74ef
-local opath=$(backup_path $scheme $path)
6f74ef
+local scheme=$( url_scheme $BACKUP_URL )
6f74ef
+local path=$( url_path $BACKUP_URL )
6f74ef
+local opath=$( backup_path $scheme $path )
6f74ef
 
6f74ef
 # if $opath is empty return silently (e.g. scheme tape)
6f74ef
 [ -z "$opath" ] && return 0
6f74ef
 
6f74ef
 if ! test -f "${opath}/.lockfile" ; then
6f74ef
     if test -d "${opath}" ; then
6f74ef
-        rm -rf $v "${opath}.old" >&2
6f74ef
-        StopIfError "Could not remove '${opath}.old'"
6f74ef
-        mv -f $v "${opath}" "${opath}.old" >&2
6f74ef
-        StopIfError "Could not move '${opath}'"
6f74ef
+        rm -rf $v "${opath}.old" || Error "Could not remove '${opath}.old'"
6f74ef
+        mv -f $v "${opath}" "${opath}.old" || Error "Could not move '${opath}'"
6f74ef
     fi
6f74ef
 else
6f74ef
     # lockfile was already made through the output workflow (hands off)
6f74ef
diff --git a/usr/share/rear/backup/NETFS/default/200_make_prefix_dir.sh b/usr/share/rear/backup/NETFS/default/200_make_prefix_dir.sh
6f74ef
index db15bca2..43f5b651 100644
6f74ef
--- a/usr/share/rear/backup/NETFS/default/200_make_prefix_dir.sh
6f74ef
+++ b/usr/share/rear/backup/NETFS/default/200_make_prefix_dir.sh
6f74ef
@@ -2,13 +2,14 @@
6f74ef
 # to $HOSTNAME
6f74ef
 
6f74ef
 # do not do this for tapes and special attention for file:///path
6f74ef
-url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
6f74ef
-local scheme=$(url_scheme ${!url})
6f74ef
-local path=$(url_path ${!url})
6f74ef
-local opath=$(backup_path $scheme $path)
6f74ef
+local scheme=$( url_scheme $BACKUP_URL )
6f74ef
+local path=$( url_path $BACKUP_URL )
6f74ef
+local opath=$( backup_path $scheme $path )
6f74ef
 
6f74ef
 # if $opath is empty return silently (e.g. scheme tape)
6f74ef
 [ -z "$opath" ] && return 0
6f74ef
 
6f74ef
-mkdir -p $v -m0750 "${opath}" >&2
6f74ef
-StopIfError "Could not mkdir '${opath}'"
6f74ef
+mkdir -p $v -m0750 "${opath}" && return
6f74ef
+
6f74ef
+# A failure to create the $NETFS_PREFIX sub-directory is fatal:
6f74ef
+Error "Failed to create '$opath' directory for BACKUP_URL=$BACKUP_URL"
6f74ef
diff --git a/usr/share/rear/backup/NETFS/default/250_create_lock.sh b/usr/share/rear/backup/NETFS/default/250_create_lock.sh
6f74ef
index 59090a22..36d547ec 100644
6f74ef
--- a/usr/share/rear/backup/NETFS/default/250_create_lock.sh
6f74ef
+++ b/usr/share/rear/backup/NETFS/default/250_create_lock.sh
6f74ef
@@ -2,15 +2,13 @@
6f74ef
 # made by a previous mkbackup run when the variable NETFS_KEEP_OLD_BACKUP_COPY has been set
6f74ef
 
6f74ef
 # do not do this for tapes and special attention for file:///path
6f74ef
-url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
6f74ef
-local scheme=$(url_scheme ${!url})
6f74ef
-local path=$(url_path ${!url})
6f74ef
-local opath=$(backup_path $scheme $path)
6f74ef
+local scheme=$( url_scheme $BACKUP_URL )
6f74ef
+local path=$( url_path $BACKUP_URL )
6f74ef
+local opath=$( backup_path $scheme $path )
6f74ef
 
6f74ef
 # if $opath is empty return silently (e.g. scheme tape)
6f74ef
 [ -z "$opath" ] && return 0
6f74ef
 
6f74ef
 if test -d "${opath}" ; then
6f74ef
-	> "${opath}/.lockfile"
6f74ef
-	StopIfError "Could not create '${opath}/.lockfile'"
6f74ef
+	> "${opath}/.lockfile" || Error "Could not create '${opath}/.lockfile'"
6f74ef
 fi
6f74ef
diff --git a/usr/share/rear/backup/NETFS/default/970_remove_lock.sh b/usr/share/rear/backup/NETFS/default/970_remove_lock.sh
6f74ef
index f69f7bd8..7038f5b9 100644
6f74ef
--- a/usr/share/rear/backup/NETFS/default/970_remove_lock.sh
6f74ef
+++ b/usr/share/rear/backup/NETFS/default/970_remove_lock.sh
6f74ef
@@ -1,8 +1,7 @@
6f74ef
 # remove the lockfile
6f74ef
-url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
6f74ef
-local scheme=$(url_scheme ${!url})
6f74ef
-local path=$(url_path ${!url})
6f74ef
-local opath=$(backup_path $scheme $path)
6f74ef
+local scheme=$( url_scheme $BACKUP_URL )
6f74ef
+local path=$( url_path $BACKUP_URL )
6f74ef
+local opath=$( backup_path $scheme $path )
6f74ef
 
6f74ef
 # if $opath is empty return silently (e.g. scheme tape)
6f74ef
 [ -z "$opath" ] && return 0
6f74ef
diff --git a/usr/share/rear/backup/NETFS/default/980_umount_NETFS_dir.sh b/usr/share/rear/backup/NETFS/default/980_umount_NETFS_dir.sh
6f74ef
index f28c6cbf..e1954dc5 100644
6f74ef
--- a/usr/share/rear/backup/NETFS/default/980_umount_NETFS_dir.sh
6f74ef
+++ b/usr/share/rear/backup/NETFS/default/980_umount_NETFS_dir.sh
6f74ef
@@ -5,9 +5,3 @@ if [[ "$BACKUP_UMOUNTCMD" ]] ; then
6f74ef
 fi
6f74ef
 
6f74ef
 umount_url $BACKUP_URL $BUILD_DIR/outputfs
6f74ef
-
6f74ef
-rmdir $v $BUILD_DIR/outputfs >&2
6f74ef
-if [[ $? -eq 0 ]] ; then
6f74ef
-    # the argument to RemoveExitTask has to be identical to the one given to AddExitTask
6f74ef
-    RemoveExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/backup/YUM/default/400_create_include_exclude_files.sh b/usr/share/rear/backup/YUM/default/400_create_include_exclude_files.sh
6f74ef
deleted file mode 100644
6f74ef
index 6111f89b..00000000
6f74ef
--- a/usr/share/rear/backup/YUM/default/400_create_include_exclude_files.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,33 +0,0 @@
6f74ef
-
6f74ef
-# Backup all that is explicitly specified in BACKUP_PROG_INCLUDE:
6f74ef
-for backup_include_item in "${BACKUP_PROG_INCLUDE[@]}" ; do
6f74ef
-    test "$backup_include_item" && echo "$backup_include_item"
6f74ef
-done > $TMP_DIR/backup-include.txt
6f74ef
-
6f74ef
-# Implicitly also backup all local filesystems as defined in mountpoint_device
6f74ef
-# except BACKUP_ONLY_INCLUDE or MANUAL_INCLUDE is set:
6f74ef
-if ! is_true "$BACKUP_ONLY_INCLUDE" ; then
6f74ef
-    if [ "${MANUAL_INCLUDE:-NO}" != "YES" ] ; then
6f74ef
-        # Add the mountpoints that will be recovered to the backup include list
6f74ef
-        # unless a mountpoint is excluded:
6f74ef
-        while read mountpoint device junk ; do
6f74ef
-            if ! IsInArray "$mountpoint" "${EXCLUDE_MOUNTPOINTS[@]}" ; then
6f74ef
-                echo "$mountpoint"
6f74ef
-            fi
6f74ef
-        done <"$VAR_DIR/recovery/mountpoint_device" >> $TMP_DIR/backup-include.txt
6f74ef
-    fi
6f74ef
-fi
6f74ef
-
6f74ef
-# Exclude all that is explicitly specified in BACKUP_PROG_EXCLUDE:
6f74ef
-for backup_exclude_item in "${BACKUP_PROG_EXCLUDE[@]}" ; do
6f74ef
-    test "$backup_exclude_item" && echo "$backup_exclude_item"
6f74ef
-done > $TMP_DIR/backup-exclude.txt
6f74ef
-
6f74ef
-# Implicitly also add excluded mountpoints to the backup exclude list
6f74ef
-# except BACKUP_ONLY_EXCLUDE is set:
6f74ef
-if ! is_true "$BACKUP_ONLY_EXCLUDE" ; then
6f74ef
-    for excluded_mountpoint in "${EXCLUDE_MOUNTPOINTS[@]}" ; do
6f74ef
-        test "$excluded_mountpoint" && echo "$excluded_mountpoint/"
6f74ef
-    done >> $TMP_DIR/backup-exclude.txt
6f74ef
-fi
6f74ef
-
6f74ef
diff --git a/usr/share/rear/backup/YUM/default/400_create_include_exclude_files.sh b/usr/share/rear/backup/YUM/default/400_create_include_exclude_files.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..d8d12c0b
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/backup/YUM/default/400_create_include_exclude_files.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../NETFS/default/400_create_include_exclude_files.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/build/YUM/default/600_create_python_symlink.sh b/usr/share/rear/build/YUM/default/600_create_python_symlink.sh
6f74ef
deleted file mode 100644
6f74ef
index 29d85905..00000000
6f74ef
--- a/usr/share/rear/build/YUM/default/600_create_python_symlink.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,14 +0,0 @@
6f74ef
-# Copied from ../../DUPLICITY/default/600_create_python_symlink.sh for YUM
6f74ef
-# make sure we have a symbolic link to the python binary
6f74ef
-(
6f74ef
-    cd  $ROOTFS_DIR/bin
6f74ef
-    for py in $(find . -name "python*" )
6f74ef
-    do
6f74ef
-        this_py=${py#./*}   # should be without ./
6f74ef
-        case $this_py in
6f74ef
-            python) break ;;
6f74ef
-            python2*|python3*) ln -sf $v $this_py python >&2 ;;
6f74ef
-        esac
6f74ef
-    done
6f74ef
-)
6f74ef
-
6f74ef
diff --git a/usr/share/rear/build/YUM/default/600_create_python_symlink.sh b/usr/share/rear/build/YUM/default/600_create_python_symlink.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..d776e5aa
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/build/YUM/default/600_create_python_symlink.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../DUPLICITY/default/600_create_python_symlink.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/lib/framework-functions.sh b/usr/share/rear/lib/framework-functions.sh
6f74ef
index f245861a..b5324747 100644
6f74ef
--- a/usr/share/rear/lib/framework-functions.sh
6f74ef
+++ b/usr/share/rear/lib/framework-functions.sh
6f74ef
@@ -122,7 +122,7 @@ function cleanup_build_area_and_end_program () {
6f74ef
     # Cleanup build area
6f74ef
     Log "Finished in $((SECONDS-STARTTIME)) seconds"
6f74ef
     if is_true "$KEEP_BUILD_DIR" ; then
6f74ef
-        LogPrint "You should also rm -Rf $BUILD_DIR"
6f74ef
+        LogPrint "You should also rm -Rf --one-file-system $BUILD_DIR"
6f74ef
     else
6f74ef
         Log "Removing build area $BUILD_DIR"
6f74ef
         rm -Rf $TMP_DIR
6f74ef
@@ -132,15 +132,11 @@ function cleanup_build_area_and_end_program () {
6f74ef
         # in worst case it could not umount; so before remove the BUILD_DIR check if above outputfs is gone
6f74ef
         if mountpoint -q "$BUILD_DIR/outputfs" ; then
6f74ef
             # still mounted it seems
6f74ef
-            LogPrint "Directory $BUILD_DIR/outputfs still mounted - trying lazy umount"
6f74ef
             sleep 2
6f74ef
-            umount -f -l $BUILD_DIR/outputfs >&2
6f74ef
-            rm -Rf $v $BUILD_DIR/outputfs >&2
6f74ef
-        else
6f74ef
-            # not mounted so we can safely delete $BUILD_DIR/outputfs
6f74ef
-            rm -Rf $BUILD_DIR/outputfs
6f74ef
+            umount_mountpoint_lazy $BUILD_DIR/outputfs
6f74ef
         fi
6f74ef
-        rm -Rf $v $BUILD_DIR >&2
6f74ef
+        remove_temporary_mountpoint '$BUILD_DIR/outputfs' || BugError "Directory $BUILD_DIR/outputfs not empty, can not remove"
6f74ef
+        rmdir $v $BUILD_DIR >&2
6f74ef
     fi
6f74ef
     Log "End of program reached"
6f74ef
 }
6f74ef
diff --git a/usr/share/rear/lib/global-functions.sh b/usr/share/rear/lib/global-functions.sh
6f74ef
index 4264bb53..a1aec604 100644
6f74ef
--- a/usr/share/rear/lib/global-functions.sh
6f74ef
+++ b/usr/share/rear/lib/global-functions.sh
6f74ef
@@ -342,7 +342,44 @@ function url_path() {
6f74ef
     echo /${url_without_scheme#*/}
6f74ef
 }
6f74ef
 
6f74ef
-backup_path() {
6f74ef
+### Returns true if one can upload files to the URL
6f74ef
+function scheme_accepts_files() {
6f74ef
+    local scheme=$1
6f74ef
+    case $scheme in
6f74ef
+        (null|tape|obdr)
6f74ef
+            # tapes do not support uploading arbitrary files, one has to handle them
6f74ef
+            # as special case (usually passing the tape device as argument to tar)
6f74ef
+            # null means do not upload anything anywhere, leave the files under /var/lib/rear/output
6f74ef
+            return 1
6f74ef
+            ;;
6f74ef
+        (*)
6f74ef
+            # most URL schemes support uploading files
6f74ef
+            return 0
6f74ef
+            ;;
6f74ef
+    esac
6f74ef
+}
6f74ef
+
6f74ef
+### Returns true if URLs with the given scheme corresponds to a path inside
6f74ef
+### a mountable fileystem and one can put files directly into it.
6f74ef
+### The actual path will be returned by backup_path() / output_path().
6f74ef
+### If returns false, using backup_path() / output_path() has no sense
6f74ef
+### and one must use a scheme-specific method (like lftp or writing them to a tape)
6f74ef
+### to upload files to the destination instead of just "cp" or other direct filesystem access.
6f74ef
+### Returning true does not imply that the URL is currently mounted at a filesystem and usable,
6f74ef
+### only that it can be mounted (use mount_url() first)
6f74ef
+function scheme_supports_filesystem() {
6f74ef
+    local scheme=$1
6f74ef
+    case $scheme in
6f74ef
+        (null|tape|obdr|rsync|fish|ftp|ftps|hftp|http|https|sftp)
6f74ef
+            return 1
6f74ef
+            ;;
6f74ef
+        (*)
6f74ef
+            return 0
6f74ef
+            ;;
6f74ef
+    esac
6f74ef
+}
6f74ef
+
6f74ef
+function backup_path() {
6f74ef
     local scheme=$1
6f74ef
     local path=$2
6f74ef
     case $scheme in
6f74ef
@@ -368,13 +405,21 @@ backup_path() {
6f74ef
     echo "$path"
6f74ef
 }
6f74ef
 
6f74ef
-output_path() {
6f74ef
+function output_path() {
6f74ef
     local scheme=$1
6f74ef
     local path=$2
6f74ef
+
6f74ef
+    # Abort for unmountable schemes ("tape-like" or "ftp-like" schemes).
6f74ef
+    # Returning an empty string for them is not satisfactory: it could lead to caller putting its files
6f74ef
+    # under / instead of the intended location if the result is not checked for emptiness.
6f74ef
+    # Returning ${BUILD_DIR}/outputfs/${OUTPUT_PREFIX} for unmountable URLs is also not satisfactory:
6f74ef
+    # caller could put its files there expecting them to be safely at their destination,
6f74ef
+    # but if the directory is not a mountpoint, they would get silently lost.
6f74ef
+    # The caller needs to check the URL/scheme using scheme_supports_filesystem()
6f74ef
+    # before calling this function.
6f74ef
+    scheme_supports_filesystem $scheme || BugError "output_path() called with scheme $scheme that does not support filesystem access"
6f74ef
+
6f74ef
     case $scheme in
6f74ef
-       (null|tape)  # no path for tape required
6f74ef
-           path=""
6f74ef
-           ;;
6f74ef
        (file)  # type file needs a local path (must be mounted by user)
6f74ef
            path="$path/${OUTPUT_PREFIX}"
6f74ef
            ;;
6f74ef
@@ -387,17 +432,33 @@ output_path() {
6f74ef
 
6f74ef
 
6f74ef
 ### Mount URL $1 at mountpoint $2[, with options $3]
6f74ef
-mount_url() {
6f74ef
+function mount_url() {
6f74ef
     local url=$1
6f74ef
     local mountpoint=$2
6f74ef
     local defaultoptions="rw,noatime"
6f74ef
     local options=${3:-"$defaultoptions"}
6f74ef
+    local scheme
6f74ef
+
6f74ef
+    scheme=$( url_scheme $url )
6f74ef
+
6f74ef
+    # The cases where we return 0 are those that do not need umount and also do not need ExitTask handling.
6f74ef
+    # They thus need to be kept in sync with umount_url() so that RemoveExitTasks is used
6f74ef
+    # iff AddExitTask was used in mount_url().
6f74ef
+
6f74ef
+    if ! scheme_supports_filesystem $scheme ; then
6f74ef
+        ### Stuff like null|tape|rsync|fish|ftp|ftps|hftp|http|https|sftp
6f74ef
+        ### Don't need to umount anything for these.
6f74ef
+        ### file: supports filesystem access, but is not mounted and unmounted,
6f74ef
+        ### so it has to be handled specially below.
6f74ef
+        ### Similarly for iso: which gets mounted and unmounted only during recovery.
6f74ef
+        return 0
6f74ef
+    fi
6f74ef
 
6f74ef
     ### Generate a mount command
6f74ef
     local mount_cmd
6f74ef
-    case $(url_scheme $url) in
6f74ef
-        (null|tape|file|rsync|fish|ftp|ftps|hftp|http|https|sftp)
6f74ef
-            ### Don't need to mount anything for these
6f74ef
+    case $scheme in
6f74ef
+        (file)
6f74ef
+            ### Don't need to mount anything for file:, it is already mounted by user
6f74ef
             return 0
6f74ef
             ;;
6f74ef
         (iso)
6f74ef
@@ -558,22 +619,47 @@ mount_url() {
6f74ef
             ;;
6f74ef
     esac
6f74ef
 
6f74ef
+    # create mount point
6f74ef
+    mkdir -p $v "$mountpoint" || Error "Could not mkdir '$mountpoint'"
6f74ef
+    AddExitTask "remove_temporary_mountpoint '$mountpoint'"
6f74ef
+
6f74ef
     Log "Mounting with '$mount_cmd'"
6f74ef
     # eval is required when mount_cmd contains single quoted stuff (e.g. see the above mount_cmd for curlftpfs)
6f74ef
     eval $mount_cmd || Error "Mount command '$mount_cmd' failed."
6f74ef
 
6f74ef
-    AddExitTask "umount -f $v '$mountpoint' >&2"
6f74ef
+    AddExitTask "perform_umount_url '$url' '$mountpoint' lazy"
6f74ef
     return 0
6f74ef
 }
6f74ef
 
6f74ef
-### Unmount url $1 at mountpoint $2
6f74ef
-umount_url() {
6f74ef
+function remove_temporary_mountpoint() {
6f74ef
+    if test -d "$1" ; then
6f74ef
+        rmdir $v "$1"
6f74ef
+    fi
6f74ef
+}
6f74ef
+
6f74ef
+### Unmount url $1 at mountpoint $2, perform mountpoint cleanup and exit task + error handling
6f74ef
+function umount_url() {
6f74ef
     local url=$1
6f74ef
     local mountpoint=$2
6f74ef
+    local scheme
6f74ef
 
6f74ef
-    case $(url_scheme $url) in
6f74ef
-        (null|tape|file|rsync|fish|ftp|ftps|hftp|http|https|sftp)
6f74ef
-            ### Don't need to umount anything for these
6f74ef
+    scheme=$( url_scheme $url )
6f74ef
+
6f74ef
+    # The cases where we return 0 are those that do not need umount and also do not need ExitTask handling.
6f74ef
+    # They thus need to be kept in sync with mount_url() so that RemoveExitTasks is used
6f74ef
+    # iff AddExitTask was used in mount_url().
6f74ef
+
6f74ef
+    if ! scheme_supports_filesystem $scheme ; then
6f74ef
+        ### Stuff like null|tape|rsync|fish|ftp|ftps|hftp|http|https|sftp
6f74ef
+        ### Don't need to umount anything for these.
6f74ef
+        ### file: supports filesystem access, but is not mounted and unmounted,
6f74ef
+        ### so it has to be handled specially below.
6f74ef
+        ### Similarly for iso: which gets mounted and unmounted only during recovery.
6f74ef
+        return 0
6f74ef
+    fi
6f74ef
+
6f74ef
+    case $scheme in
6f74ef
+        (file)
6f74ef
             return 0
6f74ef
             ;;
6f74ef
         (iso)
6f74ef
@@ -581,42 +667,106 @@ umount_url() {
6f74ef
                 return 0
6f74ef
             fi
6f74ef
             ;;
6f74ef
-	    (sshfs)
6f74ef
-	        umount_cmd="fusermount -u $mountpoint"
6f74ef
-	    ;;
6f74ef
-	    (davfs)
6f74ef
-	        umount_cmd="umount $mountpoint"
6f74ef
-            # Wait for 3 sek. then remove the cache-dir /var/cache/davfs
6f74ef
-            sleep 30
6f74ef
-            # ToDo: put in here the cache-dir from /etc/davfs2/davfs.conf
6f74ef
-            # and delete only the just used cache
6f74ef
-            #rm -rf /var/cache/davfs2/*<mountpoint-hash>*
6f74ef
-            rm -rf /var/cache/davfs2/*outputfs*
6f74ef
-
6f74ef
-	    ;;
6f74ef
-        (var)
6f74ef
-            local var=$(url_host $url)
6f74ef
-            umount_cmd="${!var} $mountpoint"
6f74ef
+        (*)
6f74ef
+            # Schemes that actually need nontrivial umount are handled below.
6f74ef
+            # We do not handle them in the default branch because in the case of iso:
6f74ef
+            # it depends on the current workflow whether umount is needed or not.
6f74ef
+            :
6f74ef
+    esac
6f74ef
 
6f74ef
-            Log "Unmounting with '$umount_cmd'"
6f74ef
-            $umount_cmd
6f74ef
-            StopIfError "Unmounting failed."
6f74ef
+    # umount_url() is a wrapper that takes care of exit tasks and error handling and mountpoint cleanup.
6f74ef
+    # Therefore it also determines if exit task and mountpoint handling is required and returns early if not.
6f74ef
+    # The actual umount job is performed inside perform_umount_url().
6f74ef
+    # We do not request lazy umount here because we want umount errors to be reliably reported.
6f74ef
+    perform_umount_url $url $mountpoint || Error "Unmounting '$mountpoint' failed."
6f74ef
 
6f74ef
-            RemoveExitTask "umount -f $v '$mountpoint' >&2"
6f74ef
-            return 0
6f74ef
+    RemoveExitTask "perform_umount_url '$url' '$mountpoint' lazy"
6f74ef
+
6f74ef
+    remove_temporary_mountpoint '$mountpoint' && RemoveExitTask "remove_temporary_mountpoint '$mountpoint'"
6f74ef
+    return 0
6f74ef
+}
6f74ef
+
6f74ef
+### Unmount url $1 at mountpoint $2 [ lazily if $3 is set to 'lazy' and normal unmount fails ]
6f74ef
+function perform_umount_url() {
6f74ef
+    local url=$1
6f74ef
+    local mountpoint=$2
6f74ef
+    local lazy=${3:-}
6f74ef
+
6f74ef
+    if test $lazy ; then
6f74ef
+        if test $lazy != "lazy" ; then
6f74ef
+            BugError "lazy = $lazy, but it must have the value of 'lazy' or empty"
6f74ef
+        fi
6f74ef
+    fi
6f74ef
+
6f74ef
+    case $(url_scheme $url) in
6f74ef
+        (sshfs)
6f74ef
+            # does ftpfs need this special case as well?
6f74ef
+            fusermount -u ${lazy:+'-z'} $mountpoint
6f74ef
+            ;;
6f74ef
+        (davfs)
6f74ef
+            umount_davfs $mountpoint $lazy
6f74ef
+            ;;
6f74ef
+        (var)
6f74ef
+            local var
6f74ef
+            var=$(url_host $url)
6f74ef
+            Log "Unmounting with '${!var} $mountpoint'"
6f74ef
+            # lazy unmount not supported with custom umount command
6f74ef
+            ${!var} $mountpoint
6f74ef
             ;;
6f74ef
+        (*)
6f74ef
+            # usual umount command
6f74ef
+            umount_mountpoint $mountpoint $lazy
6f74ef
     esac
6f74ef
+    # The switch above must be the last statement in this function and the umount commands must be
6f74ef
+    # the last commands (or part of) in each branch. This ensures proper exit code propagation
6f74ef
+    # to the caller even when set -e is used.
6f74ef
+}
6f74ef
 
6f74ef
-    umount_mountpoint $mountpoint
6f74ef
-    StopIfError "Unmounting '$mountpoint' failed."
6f74ef
+### Helper which unmounts davfs mountpoint $1 and cleans up the cache,
6f74ef
+### performing lazy unmount if $2 = 'lazy' and normal unmount fails.
6f74ef
+function umount_davfs() {
6f74ef
+    local mountpoint=$1
6f74ef
+    local lazy="${2:-}"
6f74ef
 
6f74ef
-    RemoveExitTask "umount -f $v '$mountpoint' >&2"
6f74ef
-    return 0
6f74ef
+    if test $lazy ; then
6f74ef
+        if test $lazy != "lazy" ; then
6f74ef
+            BugError "lazy = $lazy, but it must have the value of 'lazy' or empty"
6f74ef
+        fi
6f74ef
+    fi
6f74ef
+
6f74ef
+    if umount_mountpoint $mountpoint ; then
6f74ef
+        # Wait for 3 sek. then remove the cache-dir /var/cache/davfs
6f74ef
+        sleep 30
6f74ef
+        # TODO: put in here the cache-dir from /etc/davfs2/davfs.conf
6f74ef
+        # and delete only the just used cache
6f74ef
+        #rm -rf /var/cache/davfs2/*<mountpoint-hash>*
6f74ef
+        rm -rf /var/cache/davfs2/*outputfs*
6f74ef
+    else
6f74ef
+        local retval=$?
6f74ef
+
6f74ef
+        if test $lazy ; then
6f74ef
+            # try again to unmount lazily and this time do not delete the cache, it is still in use.
6f74ef
+            LogPrintError "davfs cache /var/cache/davfs2/*outputfs* needs to be cleaned up manually after the lazy unmount finishes"
6f74ef
+            umount_mountpoint_lazy $mountpoint
6f74ef
+        else
6f74ef
+            # propagate errors from umount
6f74ef
+            return $retval
6f74ef
+        fi
6f74ef
+    fi
6f74ef
 }
6f74ef
 
6f74ef
-### Unmount mountpoint $1
6f74ef
-umount_mountpoint() {
6f74ef
+### Unmount mountpoint $1 [ lazily if $2 = 'lazy' ]
6f74ef
+### Default implementation for filesystems that don't need anything fancy
6f74ef
+### For special umount commands use perform_umount_url()
6f74ef
+function umount_mountpoint() {
6f74ef
     local mountpoint=$1
6f74ef
+    local lazy=${2:-}
6f74ef
+
6f74ef
+    if test $lazy ; then
6f74ef
+        if test $lazy != "lazy" ; then
6f74ef
+            BugError "lazy = $lazy, but it must have the value of 'lazy' or empty"
6f74ef
+        fi
6f74ef
+    fi
6f74ef
 
6f74ef
     ### First, try a normal unmount,
6f74ef
     Log "Unmounting '$mountpoint'"
6f74ef
@@ -636,7 +786,21 @@ umount_mountpoint() {
6f74ef
     fi
6f74ef
 
6f74ef
     Log "Unmounting '$mountpoint' failed."
6f74ef
-    return 1
6f74ef
+
6f74ef
+    if test $lazy ; then
6f74ef
+        umount_mountpoint_lazy $mountpoint
6f74ef
+    else
6f74ef
+        return 1
6f74ef
+    fi
6f74ef
+}
6f74ef
+
6f74ef
+### Unmount mountpoint $1 lazily
6f74ef
+### Preferably use "umount_mountpoint $mountpoint lazy", which attempts non-lazy unmount first.
6f74ef
+function umount_mountpoint_lazy() {
6f74ef
+    local mountpoint=$1
6f74ef
+
6f74ef
+    LogPrint "Directory $mountpoint still mounted - trying lazy umount"
6f74ef
+    umount $v -f -l $mountpoint >&2
6f74ef
 }
6f74ef
 
6f74ef
 # Change $1 to user input or leave default value on empty input
6f74ef
diff --git a/usr/share/rear/output/PXE/default/800_copy_to_tftp.sh b/usr/share/rear/output/PXE/default/800_copy_to_tftp.sh
6f74ef
index a43dff13..3e7512ee 100644
6f74ef
--- a/usr/share/rear/output/PXE/default/800_copy_to_tftp.sh
6f74ef
+++ b/usr/share/rear/output/PXE/default/800_copy_to_tftp.sh
6f74ef
@@ -8,10 +8,12 @@
6f74ef
 if [[ ! -z "$PXE_TFTP_URL" ]] ; then
6f74ef
     # E.g. PXE_TFTP_URL=nfs://server/export/nfs/tftpboot
6f74ef
     local scheme=$( url_scheme $PXE_TFTP_URL )
6f74ef
-    local path=$( url_path $PXE_TFTP_URL )
6f74ef
-    mkdir -p $v "$BUILD_DIR/tftpbootfs" >&2
6f74ef
-    StopIfError "Could not mkdir '$BUILD_DIR/tftpbootfs'"
6f74ef
-    AddExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"
6f74ef
+
6f74ef
+    # We need filesystem access to the destination (schemes like ftp:// are not supported)
6f74ef
+    if ! scheme_supports_filesystem $scheme ; then
6f74ef
+        Error "Scheme $scheme for PXE output not supported, use a scheme that supports mounting (like nfs: )"
6f74ef
+    fi
6f74ef
+
6f74ef
     mount_url $PXE_TFTP_URL $BUILD_DIR/tftpbootfs $BACKUP_OPTIONS
6f74ef
     # However, we copy under $OUTPUT_PREFIX_PXE directory (usually HOSTNAME) to have different clients on one pxe server
6f74ef
     PXE_TFTP_LOCAL_PATH=$BUILD_DIR/tftpbootfs
6f74ef
@@ -74,10 +76,6 @@ fi
6f74ef
 if [[ ! -z "$PXE_TFTP_URL" ]] ; then
6f74ef
     LogPrint "Copied kernel+initrd $( du -shc $KERNEL_FILE "$TMP_DIR/$REAR_INITRD_FILENAME" | tail -n 1 | tr -s "\t " " " | cut -d " " -f 1 ) to $PXE_TFTP_URL/$OUTPUT_PREFIX_PXE"
6f74ef
     umount_url $PXE_TFTP_URL $BUILD_DIR/tftpbootfs
6f74ef
-    rmdir $BUILD_DIR/tftpbootfs >&2
6f74ef
-    if [[ $? -eq 0 ]] ; then
6f74ef
-        RemoveExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"
6f74ef
-    fi
6f74ef
 else
6f74ef
     # legacy way PXE_TFTP_PATH
6f74ef
     LogPrint "Copied kernel+initrd $( du -shc $KERNEL_FILE "$TMP_DIR/$REAR_INITRD_FILENAME" | tail -n 1 | tr -s "\t " " " | cut -d " " -f 1 ) to $PXE_TFTP_PATH"
6f74ef
diff --git a/usr/share/rear/output/PXE/default/810_create_pxelinux_cfg.sh b/usr/share/rear/output/PXE/default/810_create_pxelinux_cfg.sh
6f74ef
index fce4bcf1..5041a3bc 100644
6f74ef
--- a/usr/share/rear/output/PXE/default/810_create_pxelinux_cfg.sh
6f74ef
+++ b/usr/share/rear/output/PXE/default/810_create_pxelinux_cfg.sh
6f74ef
@@ -1,4 +1,4 @@
6f74ef
-# 81_create_pxelinux_cfg.sh
6f74ef
+# 810_create_pxelinux_cfg.sh
6f74ef
 #
6f74ef
 # create pxelinux config on PXE server for Relax-and-Recover
6f74ef
 #
6f74ef
@@ -11,10 +11,12 @@ if [[ ! -z "$PXE_CONFIG_URL" ]] ; then
6f74ef
     # E.g. PXE_CONFIG_URL=nfs://server/export/nfs/tftpboot/pxelinux.cfg
6f74ef
     # Better be sure that on 'server' the directory /export/nfs/tftpboot/pxelinux.cfg exists
6f74ef
     local scheme=$( url_scheme $PXE_CONFIG_URL )
6f74ef
-    local path=$( url_path $PXE_CONFIG_URL )
6f74ef
-    mkdir -p $v "$BUILD_DIR/tftpbootfs" >&2
6f74ef
-    StopIfError "Could not mkdir '$BUILD_DIR/tftpbootfs'"
6f74ef
-    AddExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"
6f74ef
+
6f74ef
+    # We need filesystem access to the destination (schemes like ftp:// are not supported)
6f74ef
+    if ! scheme_supports_filesystem $scheme ; then
6f74ef
+        Error "Scheme $scheme for PXE output not supported, use a scheme that supports mounting (like nfs: )"
6f74ef
+    fi
6f74ef
+
6f74ef
     mount_url $PXE_CONFIG_URL $BUILD_DIR/tftpbootfs $BACKUP_OPTIONS
6f74ef
     PXE_LOCAL_PATH=$BUILD_DIR/tftpbootfs
6f74ef
 else
6f74ef
@@ -105,10 +107,6 @@ popd >/dev/null
6f74ef
 if [[ ! -z "$PXE_CONFIG_URL" ]] ; then
6f74ef
     LogPrint "Created pxelinux config '${PXE_CONFIG_PREFIX}$HOSTNAME' and symlinks for $PXE_CREATE_LINKS adresses in $PXE_CONFIG_URL"
6f74ef
     umount_url $PXE_TFTP_URL $BUILD_DIR/tftpbootfs
6f74ef
-    rmdir $BUILD_DIR/tftpbootfs >&2
6f74ef
-    if [[ $? -eq 0 ]] ; then
6f74ef
-        RemoveExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"
6f74ef
-    fi
6f74ef
 else
6f74ef
     LogPrint "Created pxelinux config '${PXE_CONFIG_PREFIX}$HOSTNAME' and symlinks for $PXE_CREATE_LINKS adresses in $PXE_CONFIG_PATH"
6f74ef
     # Add to result files
6f74ef
diff --git a/usr/share/rear/output/PXE/default/820_copy_to_net.sh b/usr/share/rear/output/PXE/default/820_copy_to_net.sh
6f74ef
deleted file mode 100644
6f74ef
index 39cd316d..00000000
6f74ef
--- a/usr/share/rear/output/PXE/default/820_copy_to_net.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,41 +0,0 @@
6f74ef
-
6f74ef
-# 820_copy_to_net.sh
6f74ef
-
6f74ef
-# Check if we have a target location OUTPUT_URL
6f74ef
-test "$OUTPUT_URL" || return 0
6f74ef
-
6f74ef
-local scheme=$( url_scheme $OUTPUT_URL )
6f74ef
-local result_file=""
6f74ef
-local path=""
6f74ef
-
6f74ef
-case "$scheme" in
6f74ef
-    (nfs|cifs|usb|tape|file|davfs)
6f74ef
-        # The ISO has already been transferred by NETFS.
6f74ef
-        return 0
6f74ef
-        ;;
6f74ef
-    (fish|ftp|ftps|hftp|http|https|sftp)
6f74ef
-        LogPrint "Transferring PXE files to $OUTPUT_URL"
6f74ef
-        for result_file in "${RESULT_FILES[@]}" ; do
6f74ef
-            path=$(url_path $OUTPUT_URL)
6f74ef
-
6f74ef
-            # Make sure that destination directory exists, otherwise lftp would copy
6f74ef
-            # RESULT_FILES into last available directory in the path.
6f74ef
-            # e.g. OUTPUT_URL=sftp://<host_name>/iso/server1 and have "/iso/server1"
6f74ef
-            # directory missing, would upload RESULT_FILES into sftp://<host_name>/iso/
6f74ef
-            lftp -c "$OUTPUT_LFTP_OPTIONS; open $OUTPUT_URL; mkdir -fp ${path}"
6f74ef
-
6f74ef
-            LogPrint "Transferring file: $result_file"
6f74ef
-            lftp -c "$OUTPUT_LFTP_OPTIONS; open $OUTPUT_URL; mput $result_file" || Error "lftp failed to transfer '$result_file' to '$OUTPUT_URL' (lftp exit code: $?)"
6f74ef
-        done
6f74ef
-        ;;
6f74ef
-    (rsync)
6f74ef
-        LogPrint "Transferring PXE files to $OUTPUT_URL"
6f74ef
-        for result_file in "${RESULT_FILES[@]}" ; do
6f74ef
-            LogPrint "Transferring file: $result_file"
6f74ef
-            rsync -a $v "$result_file" "$OUTPUT_URL" || Error "Problem transferring '$result_file' to $OUTPUT_URL"
6f74ef
-        done
6f74ef
-        ;;
6f74ef
-    (*) Error "Invalid scheme '$scheme' in '$OUTPUT_URL'."
6f74ef
-        ;;
6f74ef
-esac
6f74ef
-
6f74ef
diff --git a/usr/share/rear/output/default/100_mount_output_path.sh b/usr/share/rear/output/default/100_mount_output_path.sh
6f74ef
index 22ef36de..34ea8e5e 100644
6f74ef
--- a/usr/share/rear/output/default/100_mount_output_path.sh
6f74ef
+++ b/usr/share/rear/output/default/100_mount_output_path.sh
6f74ef
@@ -1,9 +1,3 @@
6f74ef
-# create mount point
6f74ef
-mkdir -p $v "$BUILD_DIR/outputfs" >&2
6f74ef
-StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"
6f74ef
-
6f74ef
-AddExitTask "rm -Rf $v $BUILD_DIR/outputfs >&2"
6f74ef
-
6f74ef
 if [[ "$OUTPUT_MOUNTCMD" ]] ; then
6f74ef
     OUTPUT_URL="var://$OUTPUT_MOUNTCMD"
6f74ef
 fi
6f74ef
diff --git a/usr/share/rear/output/default/150_save_copy_of_prefix_dir.sh b/usr/share/rear/output/default/150_save_copy_of_prefix_dir.sh
6f74ef
index 00339a96..06326114 100644
6f74ef
--- a/usr/share/rear/output/default/150_save_copy_of_prefix_dir.sh
6f74ef
+++ b/usr/share/rear/output/default/150_save_copy_of_prefix_dir.sh
6f74ef
@@ -3,22 +3,20 @@
6f74ef
 [ -z "${KEEP_OLD_OUTPUT_COPY}" ] && return
6f74ef
 
6f74ef
 # do not do this for tapes and special attention for file:///path
6f74ef
-url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
6f74ef
-local scheme=$(url_scheme ${!url})
6f74ef
-local path=$(url_path ${!url})
6f74ef
-local opath=$(output_path $scheme $path)
6f74ef
+local scheme=$( url_scheme $OUTPUT_URL )
6f74ef
+local path=$( url_path $OUTPUT_URL )
6f74ef
 
6f74ef
-# if $opath is empty return silently (e.g. scheme tape)
6f74ef
-[ -z "$opath" ] && return 0
6f74ef
+# if filesystem access to url is unsupported return silently (e.g. scheme tape)
6f74ef
+scheme_supports_filesystem $scheme || return 0
6f74ef
+
6f74ef
+local opath=$( output_path $scheme $path )
6f74ef
 
6f74ef
 # an old lockfile from a previous run not cleaned up by output is possible
6f74ef
 [[ -f ${opath}/.lockfile ]] && rm -f ${opath}/.lockfile >&2
6f74ef
 
6f74ef
 if test -d "${opath}" ; then
6f74ef
-    rm -rf $v "${opath}.old" >&2
6f74ef
-    StopIfError "Could not remove '${opath}.old'"
6f74ef
+    rm -rf $v "${opath}.old" || Error "Could not remove '${opath}.old'"
6f74ef
     # below statement was 'cp -af' instead of 'mv -f' (see issue #192)
6f74ef
-    mv -f $v "${opath}" "${opath}.old" >&2
6f74ef
-    StopIfError "Could not move '${opath}'"
6f74ef
+    mv -f $v "${opath}" "${opath}.old" || Error "Could not move '${opath}'"
6f74ef
 fi
6f74ef
 # the ${BUILD_DIR}/outputfs/${OUTPUT_PREFIX} will be created by output/default/200_make_prefix_dir.sh
6f74ef
diff --git a/usr/share/rear/output/default/200_make_prefix_dir.sh b/usr/share/rear/output/default/200_make_prefix_dir.sh
6f74ef
index b8892f2f..606e1c86 100644
6f74ef
--- a/usr/share/rear/output/default/200_make_prefix_dir.sh
6f74ef
+++ b/usr/share/rear/output/default/200_make_prefix_dir.sh
6f74ef
@@ -3,25 +3,21 @@
6f74ef
 # The $OUTPUT_PREFIX directory defaults to $HOSTNAME.
6f74ef
 #
6f74ef
 # This happens usually under a mounted network filesystem share
6f74ef
-# e.g. in case of BACKUP_URL=nfs://NFS.server.IP.address/remote/nfs/share
6f74ef
-# but it is also happens for local stuff like BACKUP_URL=usb:///dev/disk/by-label/REAR-000
6f74ef
+# e.g. in case of OUTPUT_URL=nfs://NFS.server.IP.address/remote/nfs/share
6f74ef
+# but it is also happens for local stuff like OUTPUT_URL=usb:///dev/disk/by-label/REAR-000
6f74ef
 #
6f74ef
 # Do not do this for tapes and special attention for file:///path
6f74ef
+local scheme=$( url_scheme $OUTPUT_URL )
6f74ef
+local path=$( url_path $OUTPUT_URL )
6f74ef
 
6f74ef
-# Generate url variable name that depends on the current stage,
6f74ef
-# e.g. BACKUP_URL or OUTPUT_URL:
6f74ef
-url="$( echo $stage | tr '[:lower:]' '[:upper:]' )_URL"
6f74ef
+# If filesystem access to url is unsupported return silently (e.g. scheme tape)
6f74ef
+scheme_supports_filesystem $scheme || return 0
6f74ef
 
6f74ef
-local scheme=$( url_scheme ${!url} )
6f74ef
-local path=$( url_path ${!url} )
6f74ef
 local opath=$( output_path $scheme $path )
6f74ef
 
6f74ef
-# If $opath is empty return silently (e.g. scheme tape):
6f74ef
-test "$opath" || return 0
6f74ef
-
6f74ef
 # Create $OUTPUT_PREFIX sub-directory:
6f74ef
 mkdir -p $v -m0750 "$opath" && return
6f74ef
 
6f74ef
-# A failure to cerate the $OUTPUT_PREFIX sub-directory is fatal: 
6f74ef
-Error "Failed to create '$opath' directory for $url=${!url}"
6f74ef
+# A failure to create the $OUTPUT_PREFIX sub-directory is fatal:
6f74ef
+Error "Failed to create '$opath' directory for OUTPUT_URL=$OUTPUT_URL"
6f74ef
 
6f74ef
diff --git a/usr/share/rear/output/default/250_create_lock.sh b/usr/share/rear/output/default/250_create_lock.sh
6f74ef
index 49c75601..d792b036 100644
6f74ef
--- a/usr/share/rear/output/default/250_create_lock.sh
6f74ef
+++ b/usr/share/rear/output/default/250_create_lock.sh
6f74ef
@@ -2,15 +2,14 @@
6f74ef
 # made by a previous mkrescue run when the variable KEEP_OLD_OUTPUT_COPY has been set
6f74ef
 
6f74ef
 # do not do this for tapes and special attention for file:///path
6f74ef
-url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
6f74ef
-local scheme=$(url_scheme ${!url})
6f74ef
-local path=$(url_path ${!url})
6f74ef
-local opath=$(output_path $scheme $path)
6f74ef
+local scheme=$( url_scheme $OUTPUT_URL )
6f74ef
+local path=$( url_path $OUTPUT_URL )
6f74ef
 
6f74ef
-# if $opath is empty return silently (e.g. scheme tape)
6f74ef
-[ -z "$opath" ] && return 0
6f74ef
+# if filesystem access to url is unsupported return silently (e.g. scheme tape)
6f74ef
+scheme_supports_filesystem $scheme || return 0
6f74ef
+
6f74ef
+local opath=$( output_path $scheme $path )
6f74ef
 
6f74ef
 if test -d "${opath}" ; then
6f74ef
-    > "${opath}/.lockfile"
6f74ef
-    StopIfError "Could not create '${opath}/.lockfile'"
6f74ef
+    > "${opath}/.lockfile" || Error "Could not create '${opath}/.lockfile'"
6f74ef
 fi
6f74ef
diff --git a/usr/share/rear/output/default/950_copy_result_files.sh b/usr/share/rear/output/default/950_copy_result_files.sh
6f74ef
index 545b3f7d..77f54d51 100644
6f74ef
--- a/usr/share/rear/output/default/950_copy_result_files.sh
6f74ef
+++ b/usr/share/rear/output/default/950_copy_result_files.sh
6f74ef
@@ -5,16 +5,25 @@
6f74ef
 
6f74ef
 # For example for "rear mkbackuponly" there are usually no result files
6f74ef
 # that would need to be copied here to the output location:
6f74ef
-test "$RESULT_FILES" || return 0
6f74ef
+test "${RESULT_FILES[*]:-}" || return 0
6f74ef
 
6f74ef
 local scheme=$( url_scheme $OUTPUT_URL )
6f74ef
 local host=$( url_host $OUTPUT_URL )
6f74ef
 local path=$( url_path $OUTPUT_URL )
6f74ef
-local opath=$( output_path $scheme $path )
6f74ef
 
6f74ef
-# if $opath is empty return silently (e.g. scheme tape)
6f74ef
-if [[ -z "$opath" || -z "$OUTPUT_URL" || "$scheme" == "obdr" || "$scheme" == "tape" ]] ; then
6f74ef
-    return 0
6f74ef
+if [ -z "$OUTPUT_URL" ] || ! scheme_accepts_files $scheme ; then
6f74ef
+    if [ "$scheme" == "null" -o -z "$OUTPUT_URL" ] ; then
6f74ef
+        # There are result files to copy, but OUTPUT_URL=null indicates that we are not interested in them
6f74ef
+        # TODO: empty OUTPUT_URL seems to be equivalent to null, should we continue to allow that,
6f74ef
+        # or enforce setting it explicitly?
6f74ef
+        return 0
6f74ef
+    else
6f74ef
+        # There are files to copy, but schemes like tape: do not allow files to be stored. The files would be lost.
6f74ef
+        # Do not allow that.
6f74ef
+        # Schemes like obdr: that store the results themselves should clear RESULT_FILES to indicate that nothing is to be done.
6f74ef
+        # Is this considered a bug in ReaR (BugError), or a user misconfiguration (Error) when this happens?
6f74ef
+        BugError "Output scheme $scheme does not accept result files ${RESULT_FILES[*]}, use OUTPUT_URL=null if you don't want to copy them anywhere."
6f74ef
+    fi
6f74ef
 fi
6f74ef
 
6f74ef
 LogPrint "Copying resulting files to $scheme location"
6f74ef
@@ -38,66 +47,76 @@ RESULT_FILES+=( "$TMP_DIR/$final_logfile_name" )
6f74ef
 LogPrint "Saving $RUNTIME_LOGFILE as $final_logfile_name to $scheme location"
6f74ef
 
6f74ef
 # The real work (actually copying resulting files to the output location):
6f74ef
+if scheme_supports_filesystem $scheme ; then
6f74ef
+    # We can access the destination as a mounted filesystem. Do nothing special,
6f74ef
+    # simply copy the output files there. (Covers stuff like nfs|cifs|usb|file|sshfs|ftpfs|davfs.)
6f74ef
+    # This won't work for iso:// , but iso can't be a OUTPUT_URL scheme, this is checked in
6f74ef
+    # prep/default/040_check_backup_and_output_scheme.sh
6f74ef
+    # This covers also unknown schemes, because mount_url() will attempt to mount them and fail if this is not possible,
6f74ef
+    # so if we got here, the URL had been mounted successfully.
6f74ef
+    local opath
6f74ef
+    opath=$( output_path $scheme $path )
6f74ef
+    LogPrint "Copying result files '${RESULT_FILES[*]}' to $opath at $scheme location"
6f74ef
+    # Copy each result file one by one to avoid usually false error exits as in
6f74ef
+    # https://github.com/rear/rear/issues/1711#issuecomment-380009044
6f74ef
+    # where in case of an improper RESULT_FILES array member 'cp' can error out with something like
6f74ef
+    #   cp: will not overwrite just-created '/tmp/rear.XXX/outputfs/f121/rear-f121.log' with '/tmp/rear.XXX/tmp/rear-f121.log'
6f74ef
+    # See
6f74ef
+    # https://stackoverflow.com/questions/4669420/have-you-ever-got-this-message-when-moving-a-file-mv-will-not-overwrite-just-c
6f74ef
+    # which is about the same for 'mv', how to reproduce it:
6f74ef
+    #   mkdir a b c
6f74ef
+    #   touch a/f b/f
6f74ef
+    #   mv a/f b/f c/
6f74ef
+    #     mv: will not overwrite just-created 'c/f' with 'b/f'
6f74ef
+    # It happens because two different files with the same name would be moved to the same place with only one command.
6f74ef
+    # The -f option won't help for this case, it only applies when there already is a target file that will be overwritten.
6f74ef
+    # Accordingly it is sufficient (even without '-f') to copy each result file one by one:
6f74ef
+    for result_file in "${RESULT_FILES[@]}" ; do
6f74ef
+
6f74ef
+        # note: s390 kernel copy is only through nfs
6f74ef
+        #
6f74ef
+        # s390 optional naming override of initrd and kernel to match the s390 filesytem naming conventions
6f74ef
+        # on s390a there is an option to name the initrd and kernel in the form of
6f74ef
+        # file name on s390 are in the form of name type mode
6f74ef
+        # the name is the userid or vm name and the type is initrd or kernel
6f74ef
+        # if the vm name (cp q userid) is HOSTA then the files written will be HOSTA kernel and HOSTA initrd
6f74ef
+        # vars needed:
6f74ef
+        # ZVM_NAMING      - set in local.conf, if Y then enable naming override
6f74ef
+        # ZVM_KERNEL_NAME - keeps track of kernel name in results array
6f74ef
+        # ARCH            - override only if ARCH is Linux-s390
6f74ef
+        #
6f74ef
+        # initrd name override is handled in 900_create_initramfs.sh
6f74ef
+        # kernel name override is handled in 400_guess_kernel.sh
6f74ef
+        # kernel name override is handled in 950_copy_result_files.sh
6f74ef
+
6f74ef
+        if [[ "$ZVM_NAMING" == "Y" && "$ARCH" == "Linux-s390" ]] ; then
6f74ef
+           if [[ -z $opath ]] ; then
6f74ef
+              Error "Output path is not set, please check OUTPUT_URL in local.conf."
6f74ef
+           fi
6f74ef
+
6f74ef
+           if [ "$ZVM_KERNEL_NAME" == "$result_file" ] ; then
6f74ef
+              VM_UID=$(vmcp q userid |awk '{ print $1 }')
6f74ef
+
6f74ef
+              if [[ -z $VM_UID ]] ; then
6f74ef
+                 Error "VM UID is not set, VM UID is set from call to vmcp.  Please make sure vmcp is available and 'vmcp q userid' returns VM ID"
6f74ef
+              fi
6f74ef
+
6f74ef
+              LogPrint "s390 kernel naming override: $result_file will be written as $VM_UID.kernel"
6f74ef
+              cp $v "$result_file" $opath/$VM_UID.kernel || Error "Could not copy result file $result_file to $opath/$VM_UID.kernel at $scheme location"
6f74ef
+           else
6f74ef
+              cp $v "$result_file" $opath/ || Error "Could not copy result file $result_file to $opath at $scheme location"
6f74ef
+           fi
6f74ef
+        else
6f74ef
+           cp $v "$result_file" $opath/ || Error "Could not copy result file $result_file to $opath at $scheme location"
6f74ef
+        fi
6f74ef
+    done
6f74ef
+
6f74ef
+    return 0
6f74ef
+fi
6f74ef
+
6f74ef
+# Filesystem access to output destination not supported, use a scheme-specific tool (rsync, lftp)
6f74ef
 case "$scheme" in
6f74ef
-    (nfs|cifs|usb|file|sshfs|ftpfs|davfs)
6f74ef
-        LogPrint "Copying result files '${RESULT_FILES[@]}' to $opath at $scheme location"
6f74ef
-        # Copy each result file one by one to avoid usually false error exits as in
6f74ef
-        # https://github.com/rear/rear/issues/1711#issuecomment-380009044
6f74ef
-        # where in case of an improper RESULT_FILES array member 'cp' can error out with something like
6f74ef
-        #   cp: will not overwrite just-created '/tmp/rear.XXX/outputfs/f121/rear-f121.log' with '/tmp/rear.XXX/tmp/rear-f121.log'
6f74ef
-        # See
6f74ef
-        # https://stackoverflow.com/questions/4669420/have-you-ever-got-this-message-when-moving-a-file-mv-will-not-overwrite-just-c
6f74ef
-        # which is about the same for 'mv', how to reproduce it:
6f74ef
-        #   mkdir a b c
6f74ef
-        #   touch a/f b/f
6f74ef
-        #   mv a/f b/f c/
6f74ef
-        #     mv: will not overwrite just-created 'c/f' with 'b/f'
6f74ef
-        # It happens because two different files with the same name would be moved to the same place with only one command.
6f74ef
-        # The -f option won't help for this case, it only applies when there already is a target file that will be overwritten.
6f74ef
-        # Accordingly it is sufficient (even without '-f') to copy each result file one by one:
6f74ef
-        for result_file in "${RESULT_FILES[@]}" ; do
6f74ef
-
6f74ef
-            # note: s390 kernel copy is only through nfs
6f74ef
-            #
6f74ef
-            # s390 optional naming override of initrd and kernel to match the s390 filesytem naming conventions
6f74ef
-            # on s390a there is an option to name the initrd and kernel in the form of
6f74ef
-            # file name on s390 are in the form of name type mode
6f74ef
-            # the name is the userid or vm name and the type is initrd or kernel
6f74ef
-            # if the vm name (cp q userid) is HOSTA then the files written will be HOSTA kernel and HOSTA initrd
6f74ef
-            # vars needed:
6f74ef
-            # ZVM_NAMING      - set in local.conf, if Y then enable naming override
6f74ef
-            # ZVM_KERNEL_NAME - keeps track of kernel name in results array
6f74ef
-            # ARCH            - override only if ARCH is Linux-s390
6f74ef
-            #
6f74ef
-            # initrd name override is handled in 900_create_initramfs.sh
6f74ef
-            # kernel name override is handled in 400_guess_kernel.sh
6f74ef
-            # kernel name override is handled in 950_copy_result_files.sh
6f74ef
-
6f74ef
-            if [[ "$ZVM_NAMING" == "Y" && "$ARCH" == "Linux-s390" ]] ; then
6f74ef
-               if [[ -z $opath ]] ; then
6f74ef
-                  Error "Output path is not set, please check OUTPUT_URL in local.conf."
6f74ef
-               fi
6f74ef
-
6f74ef
-               if [ "$ZVM_KERNEL_NAME" == "$result_file" ] ; then
6f74ef
-                  VM_UID=$(vmcp q userid |awk '{ print $1 }')
6f74ef
-
6f74ef
-                  if [[ -z $VM_UID ]] ; then
6f74ef
-                     Error "VM UID is not set, VM UID is set from call to vmcp.  Please make sure vmcp is available and 'vmcp q userid' returns VM ID"
6f74ef
-                  fi
6f74ef
-
6f74ef
-                  LogPrint "s390 kernel naming override: $result_file will be written as $VM_UID.kernel"
6f74ef
-                  cp $v "$result_file" $opath/$VM_UID.kernel || Error "Could not copy result file $result_file to $opath/$VM_UID.kernel at $scheme location"
6f74ef
-               else
6f74ef
-                  cp $v "$result_file" $opath/ || Error "Could not copy result file $result_file to $opath at $scheme location"
6f74ef
-               fi
6f74ef
-            else
6f74ef
-               cp $v "$result_file" $opath/ || Error "Could not copy result file $result_file to $opath at $scheme location"
6f74ef
-            fi
6f74ef
-        done
6f74ef
-        ;;
6f74ef
     (fish|ftp|ftps|hftp|http|https|sftp)
6f74ef
-        # FIXME: Verify if usage of $array[*] instead of "${array[@]}" is actually intended here
6f74ef
-        # see https://github.com/rear/rear/issues/1068
6f74ef
         LogPrint "Copying result files '${RESULT_FILES[*]}' to $scheme location"
6f74ef
         Log "lftp -c $OUTPUT_LFTP_OPTIONS; open $OUTPUT_URL; mput ${RESULT_FILES[*]}"
6f74ef
 
6f74ef
@@ -111,12 +130,15 @@ case "$scheme" in
6f74ef
     (rsync)
6f74ef
         # If BACKUP = RSYNC output/RSYNC/default/900_copy_result_files.sh took care of it:
6f74ef
         test "$BACKUP" = "RSYNC" && return 0
6f74ef
-        LogPrint "Copying result files '${RESULT_FILES[@]}' to $scheme location"
6f74ef
-        Log "rsync -a $v ${RESULT_FILES[@]} ${host}:${path}"
6f74ef
+        LogPrint "Copying result files '${RESULT_FILES[*]}' to $scheme location"
6f74ef
+        Log "rsync -a $v ${RESULT_FILES[*]} ${host}:${path}"
6f74ef
         rsync -a $v "${RESULT_FILES[@]}" "${host}:${path}" || Error "Problem transferring result files to $OUTPUT_URL"
6f74ef
         ;;
6f74ef
     (*)
6f74ef
-        Error "Invalid scheme '$scheme' in '$OUTPUT_URL'."
6f74ef
+        # Should be unreachable, if we got here, it is a bug.
6f74ef
+        # Unknown schemes are handled in mount_url(), which tries to mount them and aborts if they are unsupported.
6f74ef
+        # If they can be mounted, they fall under the scheme_supports_filesystem branch above.
6f74ef
+        BugError "Invalid scheme '$scheme' in '$OUTPUT_URL'."
6f74ef
         ;;
6f74ef
 esac
6f74ef
 
6f74ef
diff --git a/usr/share/rear/output/default/970_remove_lock.sh b/usr/share/rear/output/default/970_remove_lock.sh
6f74ef
index 56640839..3b1b97cc 100644
6f74ef
--- a/usr/share/rear/output/default/970_remove_lock.sh
6f74ef
+++ b/usr/share/rear/output/default/970_remove_lock.sh
6f74ef
@@ -1,10 +1,11 @@
6f74ef
 # remove the lockfile
6f74ef
 local scheme=$(url_scheme $OUTPUT_URL)
6f74ef
 local path=$(url_path $OUTPUT_URL)
6f74ef
-local opath=$(output_path $scheme $path)
6f74ef
 
6f74ef
-# if $opath is empty return silently (e.g. scheme tape)
6f74ef
-[ -z "$opath" ] && return 0
6f74ef
+# if filesystem access to url is unsupported return silently (e.g. scheme tape)
6f74ef
+scheme_supports_filesystem $scheme || return 0
6f74ef
+
6f74ef
+local opath=$( output_path $scheme $path )
6f74ef
 
6f74ef
 # when OUTPUT_URL=BACKUP_URL we keep the lockfile to avoid double moves of the directory
6f74ef
 [[ "$OUTPUT_URL" != "$BACKUP_URL" ]] && rm -f $v "${opath}/.lockfile" >&2
6f74ef
diff --git a/usr/share/rear/output/default/980_umount_output_dir.sh b/usr/share/rear/output/default/980_umount_output_dir.sh
6f74ef
index 9a9995bd..abf0cd53 100644
6f74ef
--- a/usr/share/rear/output/default/980_umount_output_dir.sh
6f74ef
+++ b/usr/share/rear/output/default/980_umount_output_dir.sh
6f74ef
@@ -9,12 +9,3 @@ if [[ -z "$OUTPUT_URL" ]] ; then
6f74ef
 fi
6f74ef
 
6f74ef
 umount_url $OUTPUT_URL $BUILD_DIR/outputfs
6f74ef
-
6f74ef
-[[ -d $BUILD_DIR/outputfs/$NETFS_PREFIX ]] && rm -rf $v $BUILD_DIR/outputfs/$NETFS_PREFIX
6f74ef
-[[ -d $BUILD_DIR/outputfs/$RSYNC_PREFIX ]] && rm -rf $v $BUILD_DIR/outputfs/$RSYNC_PREFIX
6f74ef
-
6f74ef
-rmdir $v $BUILD_DIR/outputfs >&2
6f74ef
-if [[ $? -eq 0 ]] ; then
6f74ef
-    # the argument to RemoveExitTask has to be identical to the one given to AddExitTask
6f74ef
-    RemoveExitTask "rm -Rf $v $BUILD_DIR/outputfs >&2"
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/prep/BORG/default/250_mount_usb.sh b/usr/share/rear/prep/BORG/default/250_mount_usb.sh
6f74ef
index c13fd088..05be0179 100644
6f74ef
--- a/usr/share/rear/prep/BORG/default/250_mount_usb.sh
6f74ef
+++ b/usr/share/rear/prep/BORG/default/250_mount_usb.sh
6f74ef
@@ -8,10 +8,5 @@
6f74ef
 # When BORGBACKUP_HOST is set, we don't need to mount anything as SSH
6f74ef
 # backup destination will be handled internally by Borg it self.
6f74ef
 if [[ -z $BORGBACKUP_HOST ]]; then
6f74ef
-    # Has to be $verbose, not "$verbose", since it's used as option.
6f74ef
-    # shellcheck disable=SC2086,SC2154
6f74ef
-    mkdir -p $verbose "$borg_dst_dev" >&2
6f74ef
-    StopIfError "Could not mkdir '$borg_dst_dev'"
6f74ef
-
6f74ef
     mount_url "usb://$USB_DEVICE" "$borg_dst_dev"
6f74ef
 fi
6f74ef
diff --git a/usr/share/rear/prep/YUM/default/070_set_backup_archive.sh b/usr/share/rear/prep/YUM/default/070_set_backup_archive.sh
6f74ef
deleted file mode 100644
6f74ef
index 2fbcc6cd..00000000
6f74ef
--- a/usr/share/rear/prep/YUM/default/070_set_backup_archive.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,300 +0,0 @@
6f74ef
-# Copied from ../../NETFS/default/070_set_backup_archive.sh for YUM
6f74ef
-### Determine the name of the backup archive
6f74ef
-### This needs to be after we special case USB devices.
6f74ef
-
6f74ef
-# FIXME: backuparchive is no local variable (regardless that it is lowercased)
6f74ef
-
6f74ef
-# If TAPE_DEVICE is specified, use that:
6f74ef
-if test "$TAPE_DEVICE" ; then
6f74ef
-    backuparchive="$TAPE_DEVICE"
6f74ef
-    LogPrint "Using backup archive '$backuparchive'"
6f74ef
-    return
6f74ef
-fi
6f74ef
-
6f74ef
-local backup_file_suffix="$BACKUP_PROG_SUFFIX$BACKUP_PROG_COMPRESS_SUFFIX"
6f74ef
-local backup_file_name="$BACKUP_PROG_ARCHIVE$backup_file_suffix"
6f74ef
-
6f74ef
-local scheme=$( url_scheme $BACKUP_URL )
6f74ef
-local path=$( url_path $BACKUP_URL )
6f74ef
-case "$scheme" in
6f74ef
-    (file|iso)
6f74ef
-        # Define the output path according to the scheme
6f74ef
-        local outputpath=$( backup_path $scheme $path )
6f74ef
-        backuparchive="$outputpath/$backup_file_name"
6f74ef
-        LogPrint "Using backup archive '$backuparchive'"
6f74ef
-        return
6f74ef
-        ;;
6f74ef
-    (tape)
6f74ef
-        # TODO: Check if that case is really needed.
6f74ef
-        # Perhaps prep/default/030_translate_tape.sh does already all what is needed.
6f74ef
-        backuparchive=$path
6f74ef
-        LogPrint "Using backup archive '$backuparchive'"
6f74ef
-        return
6f74ef
-        ;;
6f74ef
-esac
6f74ef
-
6f74ef
-local backup_directory=$BUILD_DIR/outputfs/$NETFS_PREFIX
6f74ef
-
6f74ef
-# Normal (i.e. non-incremental/non-differential) backup:
6f74ef
-if ! test "incremental" = "$BACKUP_TYPE" -o "differential" = "$BACKUP_TYPE" ; then
6f74ef
-    # In case of normal (i.e. non-incremental) backup there is only one restore archive
6f74ef
-    # and its name is the same as the backup archive (usually 'backup.tar.gz'):
6f74ef
-    backuparchive="$backup_directory/$backup_file_name"
6f74ef
-    LogPrint "Using backup archive '$backuparchive'"
6f74ef
-    # This script is also run during "rear recover/restoreonly" where RESTORE_ARCHIVES must be set.
6f74ef
-    local backup_restore_workflows=( "recover" "restoreonly" )
6f74ef
-    if IsInArray $WORKFLOW ${backup_restore_workflows[@]} ; then
6f74ef
-        # Only set RESTORE_ARCHIVES the backup archive is actually accessible
6f74ef
-        # cf. https://github.com/rear/rear/issues/1166
6f74ef
-        if test -r "$backuparchive" ; then
6f74ef
-            RESTORE_ARCHIVES=( "$backuparchive" )
6f74ef
-        else
6f74ef
-            # In case of USB backup there is the subsequent 540_choose_backup_archive.sh script
6f74ef
-            # that shows a backup selection dialog when RESTORE_ARCHIVES is not already set.
6f74ef
-            if test "usb" = "$scheme" ; then
6f74ef
-                LogPrint "Backup archive '$backuparchive' not readable. Need to select another one."
6f74ef
-            else
6f74ef
-                Error "Backup archive '$backuparchive' not readable."
6f74ef
-            fi
6f74ef
-        fi
6f74ef
-    fi
6f74ef
-    return
6f74ef
-fi
6f74ef
-
6f74ef
-# Incremental or differential backup:
6f74ef
-set -e -u -o pipefail
6f74ef
-# Incremental or differential backup only works for the NETFS backup method
6f74ef
-# and only with the 'tar' backup program:
6f74ef
-if ! test "NETFS" = "$BACKUP" -a "tar" = "$BACKUP_PROG" ; then
6f74ef
-    Error "BACKUP_TYPE incremental or differential only works with BACKUP=NETFS and BACKUP_PROG=tar"
6f74ef
-fi
6f74ef
-# Incremental or differential backup is currently only known to work with BACKUP_URL=nfs://.
6f74ef
-# Other BACKUP_URL schemes may work and at least BACKUP_URL=usb:///... needs special setup
6f74ef
-# to work with incremental or differential backup (see https://github.com/rear/rear/issues/1145):
6f74ef
-if test "usb" = "$scheme" ; then
6f74ef
-    # When USB_SUFFIX is set the compliance mode is used where
6f74ef
-    # backup on USB works in compliance with backup on NFS which means
6f74ef
-    # a fixed backup directory where incremental or differential backups work.
6f74ef
-    # Use plain $USB_SUFFIX and not "$USB_SUFFIX" because when USB_SUFFIX contains only blanks
6f74ef
-    # test "$USB_SUFFIX" would result true because test " " results true:
6f74ef
-    test $USB_SUFFIX || Error "BACKUP_TYPE incremental or differential requires USB_SUFFIX for BACKUP_URL=usb"
6f74ef
-fi
6f74ef
-# Incremental or differential backup and keeping old backup contradict each other (mutual exclusive)
6f74ef
-# so that NETFS_KEEP_OLD_BACKUP_COPY must not be 'true' in case of incremental or differential backup:
6f74ef
-if test "$NETFS_KEEP_OLD_BACKUP_COPY" ; then
6f74ef
-    NETFS_KEEP_OLD_BACKUP_COPY=""
6f74ef
-    LogPrint "Disabled NETFS_KEEP_OLD_BACKUP_COPY because BACKUP_TYPE incremental or differential does not work with that"
6f74ef
-fi
6f74ef
-# For incremental or differential backup some date values (weekday, YYYY-MM-DD, HHMM) are needed
6f74ef
-# that must be consistent for one single point of the current time which means
6f74ef
-# one cannot call the 'date' command several times because then there would be
6f74ef
-# a small probability that e.g. weekday, YYYY-MM-DD, HHMM do not match
6f74ef
-# one single point in time (in particular when midnight passes in between).
6f74ef
-# Therefore the output of one single 'date' call is storend in an array and
6f74ef
-# the array elements are then assinged to individual variables as needed:
6f74ef
-local current_date_output=( $( date '+%a %Y-%m-%d %H%M' ) )
6f74ef
-local current_weekday="${current_date_output[0]}"
6f74ef
-local current_yyyy_mm_dd="${current_date_output[1]}"
6f74ef
-local current_hhmm="${current_date_output[2]}"
6f74ef
-# The date FULLBACKUP_OUTDATED_DAYS ago is needed to check if the latest full backup is too old.
6f74ef
-# When the latest full backup is more than FULLBACKUP_OUTDATED_DAYS ago a new full backup is made.
6f74ef
-# This separated call of the 'date' command which is technically needed because it is
6f74ef
-# for another point in time (e.g. 7 days ago) is run after the above call of the 'date'
6f74ef
-# command for the current time to be on the safe side when midnight passes in between
6f74ef
-# both 'date' commands which would then result that a new full backup is made
6f74ef
-# when the latest full backup is basically right now FULLBACKUP_OUTDATED_DAYS ago because
6f74ef
-# the stored date of the latest full backup is the current date at the time when it was made.
6f74ef
-# Example (assuming FULLBACKUP_OUTDATED_DAYS=7 ):
6f74ef
-# The latest full backup was made on Sunday January 10 in 2016 (just before midnight).
6f74ef
-# One week later this script runs again while midnight passes between the two 'date' calls
6f74ef
-# so that current_date_output[@]="Sun 2016-01-17 0000" (still Sunday January 17 in 2016)
6f74ef
-# and yyyymmdd_max_days_ago=20160111 (already Monday January 11 in 2016), then
6f74ef
-# Sunday January 10 is older than Monday January 11 so that a new full backup is made:
6f74ef
-test "$FULLBACKUP_OUTDATED_DAYS" || FULLBACKUP_OUTDATED_DAYS="7"
6f74ef
-local yyyymmdd_max_days_ago=$( date '+%Y%m%d' --date="$FULLBACKUP_OUTDATED_DAYS days ago" )
6f74ef
-# Full backup file names are of the form YYYY-MM-DD-HHMM-F.tar.gz
6f74ef
-# where the 'F' denotes a full backup:
6f74ef
-local full_backup_marker="F"
6f74ef
-# Incremental backup file names are of the form YYYY-MM-DD-HHMM-I.tar.gz
6f74ef
-# where the 'I' denotes an incremental backup:
6f74ef
-local incremental_backup_marker="I"
6f74ef
-# Differential backup file names are of the form YYYY-MM-DD-HHMM-D.tar.gz
6f74ef
-# where the last 'D' denotes a differential backup:
6f74ef
-local differential_backup_marker="D"
6f74ef
-# In case of incremental or differential backup the RESTORE_ARCHIVES contains
6f74ef
-# first the latest full backup file.
6f74ef
-# In case of incremental backup the RESTORE_ARCHIVES contains
6f74ef
-# after the latest full backup file each incremental backup
6f74ef
-# in the ordering how they must be restored.
6f74ef
-# For example when the latest full backup was made on Sunday
6f74ef
-# plus each subsequent weekday a separated incremental backup was made,
6f74ef
-# then during a "rear recover" on Wednesday morning
6f74ef
-# first the full backup from Sunday has to be restored,
6f74ef
-# then the incremental backup from Monday, and
6f74ef
-# finally the incremental backup from Tuesday.
6f74ef
-# In case of differential backup the RESTORE_ARCHIVES contains
6f74ef
-# after the latest full backup file the latest differential backup.
6f74ef
-# For example when the latest full backup was made on Sunday
6f74ef
-# plus each subsequent weekday a separated differential backup was made,
6f74ef
-# then during a "rear recover" on Wednesday morning
6f74ef
-# first the full backup from Sunday has to be restored,
6f74ef
-# and finally the differential backup from Tuesday
6f74ef
-# (i.e. the differential backup from Monday is skipped).
6f74ef
-# The date format YYYY-MM-DD that is used here is crucial.
6f74ef
-# It is the ISO 8601 format 'year-month-day' to specify a day of a year
6f74ef
-# that is accepted by 'tar' for the '--newer' option,
6f74ef
-# see the GNU tar manual section "Operating Only on New Files"
6f74ef
-# at https://www.gnu.org/software/tar/manual/html_node/after.html
6f74ef
-# and the GNU tar manual section "Calendar date items"
6f74ef
-# at https://www.gnu.org/software/tar/manual/html_node/Calendar-date-items.html#SEC124
6f74ef
-local date_glob_regex="[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]"
6f74ef
-local date_time_glob_regex="$date_glob_regex-[0-9][0-9][0-9][0-9]"
6f74ef
-# Determine what kind of backup must be created, 'full' or 'incremental' or 'differential'
6f74ef
-# (the empty default means it is undecided what kind of backup must be created):
6f74ef
-local create_backup_type=""
6f74ef
-# Code regarding creating a backup is useless during "rear recover" and
6f74ef
-# messages about creating a backup are misleading during "rear recover":
6f74ef
-local recovery_workflows=( "recover" "layoutonly" "restoreonly" )
6f74ef
-if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-    # When today is a specified full backup day, do a full backup in any case
6f74ef
-    # (regardless if there is already a full backup of this day):
6f74ef
-    if IsInArray "$current_weekday" "${FULLBACKUPDAY[@]}" ; then
6f74ef
-        create_backup_type="full"
6f74ef
-        LogPrint "Today's weekday ('$current_weekday') is a full backup day that triggers a new full backup in any case"
6f74ef
-    fi
6f74ef
-fi
6f74ef
-# Get the latest full backup (if exists):
6f74ef
-local full_backup_glob_regex="$date_time_glob_regex-$full_backup_marker$backup_file_suffix"
6f74ef
-# Here things like 'find /path/to/dir -name '*.tar.gz' | sort' are used because
6f74ef
-# one cannot use bash globbing via commands like 'ls /path/to/dir/*.tar.gz'
6f74ef
-# because /usr/sbin/rear sets the nullglob bash option which leads to plain 'ls'
6f74ef
-# when '/path/to/dir/*.tar.gz' matches nothing (i.e. when no backup file exists)
6f74ef
-# so that then plain 'ls' would result nonsense.
6f74ef
-local latest_full_backup=$( find $backup_directory -name "$full_backup_glob_regex" | sort | tail -n1 )
6f74ef
-# A latest full backup is found:
6f74ef
-if test "$latest_full_backup" ; then
6f74ef
-    local latest_full_backup_file_name=$( basename "$latest_full_backup" )
6f74ef
-    # The full_or_incremental_backup_glob_regex is also needed below for non-"recover" WORKFLOWs
6f74ef
-    # to set the right variables for creating an incremental backup:
6f74ef
-    local full_or_incremental_backup_glob_regex="$date_time_glob_regex-[$full_backup_marker$incremental_backup_marker]$backup_file_suffix"
6f74ef
-    # Code regarding creating a backup is useless during "rear recover" and
6f74ef
-    # messages about creating a backup are misleading during "rear recover":
6f74ef
-    if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-        # There is nothing to do here if it is already decided that
6f74ef
-        # a full backup must be created (see "full backup day" above"):
6f74ef
-        if ! test "full" = "$create_backup_type" ; then
6f74ef
-            local latest_full_backup_date=$( echo $latest_full_backup_file_name | grep -o "$date_glob_regex" )
6f74ef
-            local yyyymmdd_latest_full_backup=$( echo $latest_full_backup_date | tr -d '-' )
6f74ef
-            # Check if the latest full backup is too old:
6f74ef
-            if test $yyyymmdd_latest_full_backup -lt $yyyymmdd_max_days_ago ; then
6f74ef
-                create_backup_type="full"
6f74ef
-                LogPrint "Latest full backup date '$latest_full_backup_date' too old (more than $FULLBACKUP_OUTDATED_DAYS days ago) triggers new full backup"
6f74ef
-            else
6f74ef
-                # When a latest full backup is found that is not too old
6f74ef
-                # a BACKUP_TYPE (incremental or differential) backup will be created:
6f74ef
-                create_backup_type="$BACKUP_TYPE"
6f74ef
-                LogPrint "Latest full backup found ($latest_full_backup_file_name) triggers $BACKUP_TYPE backup"
6f74ef
-            fi
6f74ef
-        fi
6f74ef
-    else
6f74ef
-        # This script is also run during "rear recover" where RESTORE_ARCHIVES must be set:
6f74ef
-        case "$BACKUP_TYPE" in
6f74ef
-            (incremental)
6f74ef
-                # When a latest full backup is found use that plus all later incremental backups for restore:
6f74ef
-                # The following command is a bit tricky:
6f74ef
-                # It lists all YYYY-MM-DD-HHMM-F.tar.gz and all YYYY-MM-DD-HHMM-I.tar.gz files in the backup directory and sorts them
6f74ef
-                # and finally it outputs only those that match the latest full backup file name and incremental backups that got sorted after that
6f74ef
-                # where it is mandatory that the backup file names sort by date (i.e. date must be the leading part of the backup file names):
6f74ef
-                RESTORE_ARCHIVES=( $( find $backup_directory -name "$full_or_incremental_backup_glob_regex" | sort | sed -n -e "/$latest_full_backup_file_name/,\$p" ) )
6f74ef
-                ;;
6f74ef
-            (differential)
6f74ef
-                # For differential backup use the latest full backup plus the one latest differential backup for restore:
6f74ef
-                # The following command is a bit tricky:
6f74ef
-                # It lists all YYYY-MM-DD-HHMM-F.tar.gz and all YYYY-MM-DD-HHMM-D.tar.gz files in the backup directory and sorts them
6f74ef
-                # then it outputs only those that match the latest full backup file name and all differential backups that got sorted after that
6f74ef
-                # and then it outputs only the first line (i.e. the full backup) and the last line (i.e. the latest differential backup)
6f74ef
-                # but when no differential backup exists (i.e. when only the full backup exists) the first line is also the last line
6f74ef
-                # so that "sed -n -e '1p;$p'" outputs the full backup twice which is corrected by the final "sort -u":
6f74ef
-                local full_or_differential_backup_glob_regex="$date_time_glob_regex-[$full_backup_marker$differential_backup_marker]$backup_file_suffix"
6f74ef
-                RESTORE_ARCHIVES=( $( find $backup_directory -name "$full_or_differential_backup_glob_regex" | sort | sed -n -e "/$latest_full_backup_file_name/,\$p" | sed -n -e '1p;$p' | sort -u ) )
6f74ef
-                ;;
6f74ef
-            (*)
6f74ef
-                BugError "Unexpected BACKUP_TYPE '$BACKUP_TYPE'"
6f74ef
-                ;;
6f74ef
-        esac
6f74ef
-        # Tell the user what will be restored:
6f74ef
-        local restore_archives_file_names=""
6f74ef
-        for restore_archive in "${RESTORE_ARCHIVES[@]}" ; do
6f74ef
-            restore_archives_file_names="$restore_archives_file_names $( basename "$restore_archive" )"
6f74ef
-        done
6f74ef
-        LogPrint "For backup restore using $restore_archives_file_names"
6f74ef
-    fi
6f74ef
-# No latest full backup is found:
6f74ef
-else
6f74ef
-    # Code regarding creating a backup is useless during "rear recover" and
6f74ef
-    # messages about creating a backup are misleading during "rear recover":
6f74ef
-    if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-        # If no latest full backup is found create one during "rear mkbackup":
6f74ef
-        create_backup_type="full"
6f74ef
-        LogPrint "No full backup found (YYYY-MM-DD-HHMM-F.tar.gz) triggers full backup"
6f74ef
-    else
6f74ef
-        # This script is also run during "rear recover" where RESTORE_ARCHIVES must be set:
6f74ef
-        # If no latest full backup is found (i.e. no file name matches the YYYY-MM-DD-HHMM-F.tar.gz form)
6f74ef
-        # fall back to what is done in case of normal (i.e. non-incremental/non-differential) backup
6f74ef
-        # and hope for the best (i.e. that a backup_directory/backup_file_name actually exists).
6f74ef
-        # In case of normal (i.e. non-incremental/non-differential) backup there is only one restore archive
6f74ef
-        # and its name is the same as the backup archive (usually 'backup.tar.gz').
6f74ef
-        # This is only a fallback setting to be more on the safe side for "rear recover".
6f74ef
-        # Initially for the very fist run of incremental backup during "rear mkbackup"
6f74ef
-        # a full backup file of the YYYY-MM-DD-HHMM-F.tar.gz form will be created.
6f74ef
-        RESTORE_ARCHIVES=( "$backup_directory/$backup_file_name" )
6f74ef
-        LogPrint "Using $backup_file_name for backup restore"
6f74ef
-    fi
6f74ef
-fi
6f74ef
-# Code regarding creating a backup is useless during "rear recover" and
6f74ef
-# messages about creating a backup are misleading during "rear recover":
6f74ef
-if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-    # Set the right variables for creating a backup (but do not actually do anything at this point):
6f74ef
-    case "$create_backup_type" in
6f74ef
-        (full)
6f74ef
-            local new_full_backup_file_name="$current_yyyy_mm_dd-$current_hhmm-$full_backup_marker$backup_file_suffix"
6f74ef
-            backuparchive="$backup_directory/$new_full_backup_file_name"
6f74ef
-            BACKUP_PROG_CREATE_NEWER_OPTIONS="-V $new_full_backup_file_name"
6f74ef
-            LogPrint "Performing full backup using backup archive '$new_full_backup_file_name'"
6f74ef
-            ;;
6f74ef
-        (incremental)
6f74ef
-            local new_incremental_backup_file_name="$current_yyyy_mm_dd-$current_hhmm-$incremental_backup_marker$backup_file_suffix"
6f74ef
-            backuparchive="$backup_directory/$new_incremental_backup_file_name"
6f74ef
-            # Get the latest latest incremental backup that is based on the latest full backup (if exists):
6f74ef
-            local incremental_backup_glob_regex="$date_time_glob_regex-$incremental_backup_marker$backup_file_suffix"
6f74ef
-            # First get the latest full backup plus all later incremental backups (cf. how RESTORE_ARCHIVES is set in case of incremental backup)
6f74ef
-            # then grep only the incremental backups and from the incremental backups use only the last one (if exists):
6f74ef
-            local latest_incremental_backup=$( find $backup_directory -name "$full_or_incremental_backup_glob_regex" | sort | sed -n -e "/$latest_full_backup_file_name/,\$p" | grep "$incremental_backup_glob_regex" | tail -n1 )
6f74ef
-            if test "$latest_incremental_backup" ; then
6f74ef
-                # A latest incremental backup that is based on the latest full backup is found:
6f74ef
-                local latest_incremental_backup_file_name=$( basename $latest_incremental_backup )
6f74ef
-                LogPrint "Latest incremental backup found ($latest_incremental_backup_file_name) that is newer than the latest full backup"
6f74ef
-                local latest_incremental_backup_date=$( echo $latest_incremental_backup_file_name | grep -o "$date_glob_regex" )
6f74ef
-                BACKUP_PROG_CREATE_NEWER_OPTIONS="--newer=$latest_incremental_backup_date -V $latest_incremental_backup_file_name"
6f74ef
-                LogPrint "Performing incremental backup for files newer than $latest_incremental_backup_date using backup archive '$new_incremental_backup_file_name'"
6f74ef
-            else
6f74ef
-                # When there is not yet an incremental backup that is based on the latest full backup
6f74ef
-                # the new created incremental backup must be based on the latest full backup:
6f74ef
-                BACKUP_PROG_CREATE_NEWER_OPTIONS="--newer=$latest_full_backup_date -V $latest_full_backup_file_name"
6f74ef
-                LogPrint "Performing incremental backup for files newer than $latest_full_backup_date using backup archive '$new_incremental_backup_file_name'"
6f74ef
-            fi
6f74ef
-            ;;
6f74ef
-        (differential)
6f74ef
-            local new_differential_backup_file_name="$current_yyyy_mm_dd-$current_hhmm-$differential_backup_marker$backup_file_suffix"
6f74ef
-            backuparchive="$backup_directory/$new_differential_backup_file_name"
6f74ef
-            BACKUP_PROG_CREATE_NEWER_OPTIONS="--newer=$latest_full_backup_date -V $latest_full_backup_file_name"
6f74ef
-            LogPrint "Performing differential backup for files newer than $latest_full_backup_date using backup archive '$new_differential_backup_file_name'"
6f74ef
-            ;;
6f74ef
-        (*)
6f74ef
-            BugError "Unexpected create_backup_type '$create_backup_type'"
6f74ef
-            ;;
6f74ef
-    esac
6f74ef
-fi
6f74ef
-# Go back from "set -e -u -o pipefail" to the defaults:
6f74ef
-apply_bash_flags_and_options_commands "$DEFAULT_BASH_FLAGS_AND_OPTIONS_COMMANDS"
6f74ef
-
6f74ef
diff --git a/usr/share/rear/prep/YUM/default/070_set_backup_archive.sh b/usr/share/rear/prep/YUM/default/070_set_backup_archive.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..cdbdc31f
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/prep/YUM/default/070_set_backup_archive.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../NETFS/default/070_set_backup_archive.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/restore/DUPLICITY/default/100_mount_duplicity_path.sh b/usr/share/rear/restore/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
deleted file mode 100644
6f74ef
index 64b7a792..00000000
6f74ef
--- a/usr/share/rear/restore/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,15 +0,0 @@
6f74ef
-# create mount point
6f74ef
-if [ -n "$BACKUP_DUPLICITY_NETFS_URL" -o -n "$BACKUP_DUPLICITY_NETFS_MOUNTCMD" ]; then
6f74ef
-	mkdir -p $v "$BUILD_DIR/outputfs" >&2
6f74ef
-	StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"
6f74ef
-
6f74ef
-	AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-
6f74ef
-	if [[ "$BACKUP_DUPLICITY_NETFS_MOUNTCMD" ]] ; then
6f74ef
-		BACKUP_DUPLICITY_NETFS_URL="var://BACKUP_DUPLICITY_NETFS_MOUNTCMD"
6f74ef
-	fi
6f74ef
-
6f74ef
-	mount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs $BACKUP_DUPLICITY_NETFS_OPTIONS
6f74ef
-	
6f74ef
-	BACKUP_DUPLICITY_URL="file://$BUILD_DIR/outputfs"
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/restore/DUPLICITY/default/100_mount_duplicity_path.sh b/usr/share/rear/restore/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..7f558c5d
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/restore/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../../backup/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/restore/DUPLICITY/default/980_unmount_duplicity_path.sh b/usr/share/rear/restore/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
deleted file mode 100644
6f74ef
index 60aa811e..00000000
6f74ef
--- a/usr/share/rear/restore/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,15 +0,0 @@
6f74ef
-# umount mountpoint
6f74ef
-if [ -n "$BACKUP_DUPLICITY_NETFS_URL" -o -n "$BACKUP_DUPLICITY_NETFS_UMOUNTCMD" ]; then
6f74ef
-
6f74ef
-	if [[ "$BACKUP_DUPLICITY_NETFS_UMOUNTCMD" ]] ; then
6f74ef
-		BACKUP_DUPLICITY_NETFS_URL="var://BACKUP_DUPLICITY_NETFS_UMOUNTCMD"
6f74ef
-	fi
6f74ef
-
6f74ef
-	umount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs
6f74ef
-
6f74ef
-	rmdir $v $BUILD_DIR/outputfs >&2
6f74ef
-	if [[ $? -eq 0 ]] ; then
6f74ef
-		# the argument to RemoveExitTask has to be identical to the one given to AddExitTask
6f74ef
-		RemoveExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-	fi
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/restore/DUPLICITY/default/980_unmount_duplicity_path.sh b/usr/share/rear/restore/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..b7e47be1
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/restore/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../../backup/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh b/usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh
6f74ef
deleted file mode 100644
6f74ef
index 7de92af4..00000000
6f74ef
--- a/usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,13 +0,0 @@
6f74ef
-# Copied from ../../NETFS/default/100_mount_NETFS_path.sh a.k.a. ../../../backup/NETFS/default/100_mount_NETFS_path.sh for YUM
6f74ef
-
6f74ef
-# create mount point
6f74ef
-mkdir -p $v "$BUILD_DIR/outputfs" >&2
6f74ef
-StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"
6f74ef
-
6f74ef
-AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-
6f74ef
-if [[ "$BACKUP_MOUNTCMD" ]] ; then
6f74ef
-    BACKUP_URL="var://BACKUP_MOUNTCMD"
6f74ef
-fi
6f74ef
-
6f74ef
-mount_url $BACKUP_URL $BUILD_DIR/outputfs $BACKUP_OPTIONS
6f74ef
diff --git a/usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh b/usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..60e0f83f
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/restore/YUM/default/100_mount_YUM_path.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../NETFS/default/100_mount_NETFS_path.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh b/usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh
6f74ef
deleted file mode 100644
6f74ef
index d02dcf34..00000000
6f74ef
--- a/usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,15 +0,0 @@
6f74ef
-# Copied from ../../../backup/NETFS/default/980_umount_NETFS_dir.sh for YUM
6f74ef
-
6f74ef
-# umount NETFS mountpoint
6f74ef
-
6f74ef
-if [[ "$BACKUP_UMOUNTCMD" ]] ; then
6f74ef
-    BACKUP_URL="var://BACKUP_UMOUNTCMD"
6f74ef
-fi
6f74ef
-
6f74ef
-umount_url $BACKUP_URL $BUILD_DIR/outputfs
6f74ef
-
6f74ef
-rmdir $v $BUILD_DIR/outputfs >&2
6f74ef
-if [[ $? -eq 0 ]] ; then
6f74ef
-    # the argument to RemoveExitTask has to be identical to the one given to AddExitTask
6f74ef
-    RemoveExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh b/usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..2c29cb57
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../NETFS/default/980_umount_NETFS_dir.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/verify/DUPLICITY/default/100_mount_duplicity_path.sh b/usr/share/rear/verify/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
deleted file mode 100644
6f74ef
index 64b7a792..00000000
6f74ef
--- a/usr/share/rear/verify/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,15 +0,0 @@
6f74ef
-# create mount point
6f74ef
-if [ -n "$BACKUP_DUPLICITY_NETFS_URL" -o -n "$BACKUP_DUPLICITY_NETFS_MOUNTCMD" ]; then
6f74ef
-	mkdir -p $v "$BUILD_DIR/outputfs" >&2
6f74ef
-	StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"
6f74ef
-
6f74ef
-	AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-
6f74ef
-	if [[ "$BACKUP_DUPLICITY_NETFS_MOUNTCMD" ]] ; then
6f74ef
-		BACKUP_DUPLICITY_NETFS_URL="var://BACKUP_DUPLICITY_NETFS_MOUNTCMD"
6f74ef
-	fi
6f74ef
-
6f74ef
-	mount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs $BACKUP_DUPLICITY_NETFS_OPTIONS
6f74ef
-	
6f74ef
-	BACKUP_DUPLICITY_URL="file://$BUILD_DIR/outputfs"
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/verify/DUPLICITY/default/100_mount_duplicity_path.sh b/usr/share/rear/verify/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..7f558c5d
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/verify/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../../backup/DUPLICITY/default/100_mount_duplicity_path.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/verify/DUPLICITY/default/980_unmount_duplicity_path.sh b/usr/share/rear/verify/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
deleted file mode 100644
6f74ef
index 60aa811e..00000000
6f74ef
--- a/usr/share/rear/verify/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,15 +0,0 @@
6f74ef
-# umount mountpoint
6f74ef
-if [ -n "$BACKUP_DUPLICITY_NETFS_URL" -o -n "$BACKUP_DUPLICITY_NETFS_UMOUNTCMD" ]; then
6f74ef
-
6f74ef
-	if [[ "$BACKUP_DUPLICITY_NETFS_UMOUNTCMD" ]] ; then
6f74ef
-		BACKUP_DUPLICITY_NETFS_URL="var://BACKUP_DUPLICITY_NETFS_UMOUNTCMD"
6f74ef
-	fi
6f74ef
-
6f74ef
-	umount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs
6f74ef
-
6f74ef
-	rmdir $v $BUILD_DIR/outputfs >&2
6f74ef
-	if [[ $? -eq 0 ]] ; then
6f74ef
-		# the argument to RemoveExitTask has to be identical to the one given to AddExitTask
6f74ef
-		RemoveExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-	fi
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/verify/DUPLICITY/default/980_unmount_duplicity_path.sh b/usr/share/rear/verify/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..b7e47be1
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/verify/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../../backup/DUPLICITY/default/980_unmount_duplicity_path.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/050_check_YUM_requirements.sh b/usr/share/rear/verify/YUM/default/050_check_YUM_requirements.sh
6f74ef
deleted file mode 100644
6f74ef
index cfd70026..00000000
6f74ef
--- a/usr/share/rear/verify/YUM/default/050_check_YUM_requirements.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,116 +0,0 @@
6f74ef
-# Copied from ../../../prep/NETFS/default/050_check_NETFS_requirements.sh for YUM
6f74ef
-# BACKUP_URL=[proto]://[host]/[share]
6f74ef
-# example: nfs://lucky/temp/backup
6f74ef
-# example: cifs://lucky/temp
6f74ef
-# example: usb:///dev/sdb1
6f74ef
-# example: tape:///dev/nst0
6f74ef
-# example: file:///path
6f74ef
-# example: iso://backup/
6f74ef
-# example: sshfs://user@host/G/rear/
6f74ef
-# example: ftpfs://user:password@host/rear/ (the password part is optional)
6f74ef
-
6f74ef
-[[ "$BACKUP_URL" || "$BACKUP_MOUNTCMD" ]]
6f74ef
-# FIXME: The above test does not match the error message below.
6f74ef
-# To match the the error message the test should be
6f74ef
-# [[ "$BACKUP_URL" || ( "$BACKUP_MOUNTCMD" && "$BACKUP_UMOUNTCMD" ) ]]
6f74ef
-# but I <jsmeix@suse.de> cannot decide if there is a subtle reason for the omission.
6f74ef
-StopIfError "You must specify either BACKUP_URL or BACKUP_MOUNTCMD and BACKUP_UMOUNTCMD !"
6f74ef
-
6f74ef
-if [[ "$BACKUP_URL" ]] ; then
6f74ef
-    local scheme=$( url_scheme $BACKUP_URL )
6f74ef
-    local hostname=$( url_hostname $BACKUP_URL )
6f74ef
-    local path=$( url_path $BACKUP_URL )
6f74ef
-
6f74ef
-    ### check for vaild BACKUP_URL schemes
6f74ef
-    ### see https://github.com/rear/rear/issues/842
6f74ef
-    case $scheme in
6f74ef
-        (nfs|cifs|usb|tape|file|iso|sshfs|ftpfs)
6f74ef
-            # do nothing for vaild BACKUP_URL schemes
6f74ef
-            :
6f74ef
-            ;;
6f74ef
-        (*)
6f74ef
-            Error "Invalid scheme '$scheme' in BACKUP_URL '$BACKUP_URL' valid schemes: nfs cifs usb tape file iso sshfs ftpfs"
6f74ef
-            ;;
6f74ef
-    esac
6f74ef
-
6f74ef
-    ### set other variables from BACKUP_URL
6f74ef
-    if [[ "usb" = "$scheme" ]] ; then
6f74ef
-        # if USB_DEVICE is not explicitly specified it is the path from BACKUP_URL
6f74ef
-        [[ -z "$USB_DEVICE" ]] && USB_DEVICE="$path"
6f74ef
-    fi
6f74ef
-
6f74ef
-    ### check if host is reachable
6f74ef
-    if [[ "$PING" && "$hostname" ]] ; then
6f74ef
-        # Only LogPrintIfError but no StopIfError because it is not a fatal error
6f74ef
-        # (i.e. not a reason to abort) when a host does not respond to a 'ping'
6f74ef
-        # because hosts can be accessible via certain ports but do not respond to a 'ping'
6f74ef
-        # cf. https://bugzilla.opensuse.org/show_bug.cgi?id=616706
6f74ef
-        # TODO: it would be better to test if it is accessible via the actually needed port(s)
6f74ef
-        ping -c 2 "$hostname" >/dev/null
6f74ef
-        LogPrintIfError "Host '$hostname' in BACKUP_URL '$BACKUP_URL' does not respond to a 'ping'."
6f74ef
-    else
6f74ef
-        Log "Skipping 'ping' test for host '$hostname' in BACKUP_URL '$BACKUP_URL'"
6f74ef
-    fi
6f74ef
-
6f74ef
-fi
6f74ef
-
6f74ef
-# some backup progs require a different backuparchive name
6f74ef
-case "$(basename $BACKUP_PROG)" in
6f74ef
-    (rsync)
6f74ef
-        # rsync creates a target directory instead of a file
6f74ef
-        BACKUP_PROG_SUFFIX=
6f74ef
-        BACKUP_PROG_COMPRESS_SUFFIX=
6f74ef
-        ;;
6f74ef
-    (*)
6f74ef
-        :
6f74ef
-        ;;
6f74ef
-esac
6f74ef
-
6f74ef
-# include required programs
6f74ef
-# the code below includes mount.* and umount.* programs for all non-empty schemes
6f74ef
-# (i.e. for any non-empty BACKUP_URL like usb tape file sshfs ftpfs)
6f74ef
-# and it includes 'mount.' for empty schemes (e.g. if BACKUP_URL is not set)
6f74ef
-# which is o.k. because it is a catch all rule so we do not miss any
6f74ef
-# important executable needed a certain scheme and it does not hurt
6f74ef
-# see https://github.com/rear/rear/pull/859
6f74ef
-PROGS+=(
6f74ef
-showmount
6f74ef
-mount.$(url_scheme $BACKUP_URL)
6f74ef
-umount.$(url_scheme $BACKUP_URL)
6f74ef
-$( test "$BACKUP_MOUNTCMD" && echo "${BACKUP_MOUNTCMD%% *}" )
6f74ef
-$( test "$BACKUP_UMOUNTCMD" && echo "${BACKUP_UMOUNTCMD%% *}" )
6f74ef
-$BACKUP_PROG
6f74ef
-gzip
6f74ef
-bzip2
6f74ef
-xz
6f74ef
-)
6f74ef
-
6f74ef
-# include required stuff for sshfs or ftpfs (via CurlFtpFS)
6f74ef
-if [[ "sshfs" = "$scheme" || "ftpfs" = "$scheme" ]] ; then
6f74ef
-    # both sshfs and ftpfs (via CurlFtpFS) are based on FUSE
6f74ef
-    PROGS+=( fusermount mount.fuse )
6f74ef
-    MODULES+=( fuse )
6f74ef
-    MODULES_LOAD+=( fuse )
6f74ef
-    COPY_AS_IS+=( /etc/fuse.conf )
6f74ef
-    # include what is specific for sshfs
6f74ef
-    if [[ "sshfs" = "$scheme" ]] ; then
6f74ef
-        # see http://sourceforge.net/apps/mediawiki/fuse/index.php?title=SshfsFaq
6f74ef
-        REQUIRED_PROGS+=( sshfs ssh )
6f74ef
-        # relying on 500_ssh.sh to take a long the SSH related files
6f74ef
-    fi
6f74ef
-    # include what is specific for ftpfs
6f74ef
-    if [[ "ftpfs" = "$scheme" ]] ; then
6f74ef
-        # see http://curlftpfs.sourceforge.net/
6f74ef
-        # and https://github.com/rear/rear/issues/845
6f74ef
-        REQUIRED_PROGS+=( curlftpfs )
6f74ef
-    fi
6f74ef
-fi
6f74ef
-
6f74ef
-# include required modules, like nfs cifs ...
6f74ef
-# the code below includes modules for all non-empty schemes
6f74ef
-# (i.e. for any non-empty BACKUP_URL like usb tape file sshfs ftpfs)
6f74ef
-# which is o.k. because this must been seen as a catch all rule
6f74ef
-# (one never knows what one could miss)
6f74ef
-# see https://github.com/rear/rear/pull/859
6f74ef
-MODULES+=( $(url_scheme $BACKUP_URL) )
6f74ef
-
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/050_check_YUM_requirements.sh b/usr/share/rear/verify/YUM/default/050_check_YUM_requirements.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..af1512d6
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/verify/YUM/default/050_check_YUM_requirements.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../NETFS/default/050_check_NETFS_requirements.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh b/usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh
6f74ef
deleted file mode 100644
6f74ef
index f7e31ed6..00000000
6f74ef
--- a/usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,12 +0,0 @@
6f74ef
-# Copied from ../../../backup/NETFS/default/100_mount_NETFS_path.sh for YUM
6f74ef
-# create mount point
6f74ef
-mkdir -p $v "$BUILD_DIR/outputfs" >&2
6f74ef
-StopIfError "Could not mkdir '$BUILD_DIR/outputfs'"
6f74ef
-
6f74ef
-AddExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-
6f74ef
-if [[ "$BACKUP_MOUNTCMD" ]] ; then
6f74ef
-    BACKUP_URL="var://BACKUP_MOUNTCMD"
6f74ef
-fi
6f74ef
-
6f74ef
-mount_url $BACKUP_URL $BUILD_DIR/outputfs $BACKUP_OPTIONS
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh b/usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..73dd4697
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/verify/YUM/default/060_mount_YUM_path.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../../restore/YUM/default/100_mount_YUM_path.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/070_set_backup_archive.sh b/usr/share/rear/verify/YUM/default/070_set_backup_archive.sh
6f74ef
deleted file mode 100644
6f74ef
index 86d1708d..00000000
6f74ef
--- a/usr/share/rear/verify/YUM/default/070_set_backup_archive.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,300 +0,0 @@
6f74ef
-# Copied from ../../../prep/NETFS/default/070_set_backup_archive.sh for YUM
6f74ef
-### Determine the name of the backup archive
6f74ef
-### This needs to be after we special case USB devices.
6f74ef
-
6f74ef
-# FIXME: backuparchive is no local variable (regardless that it is lowercased)
6f74ef
-
6f74ef
-# If TAPE_DEVICE is specified, use that:
6f74ef
-if test "$TAPE_DEVICE" ; then
6f74ef
-    backuparchive="$TAPE_DEVICE"
6f74ef
-    LogPrint "Using backup archive '$backuparchive'"
6f74ef
-    return
6f74ef
-fi
6f74ef
-
6f74ef
-local backup_file_suffix="$BACKUP_PROG_SUFFIX$BACKUP_PROG_COMPRESS_SUFFIX"
6f74ef
-local backup_file_name="$BACKUP_PROG_ARCHIVE$backup_file_suffix"
6f74ef
-
6f74ef
-local scheme=$( url_scheme $BACKUP_URL )
6f74ef
-local path=$( url_path $BACKUP_URL )
6f74ef
-case "$scheme" in
6f74ef
-    (file|iso)
6f74ef
-        # Define the output path according to the scheme
6f74ef
-        local outputpath=$( backup_path $scheme $path )
6f74ef
-        backuparchive="$outputpath/$backup_file_name"
6f74ef
-        LogPrint "Using backup archive '$backuparchive'"
6f74ef
-        return
6f74ef
-        ;;
6f74ef
-    (tape)
6f74ef
-        # TODO: Check if that case is really needed.
6f74ef
-        # Perhaps prep/default/030_translate_tape.sh does already all what is needed.
6f74ef
-        backuparchive=$path
6f74ef
-        LogPrint "Using backup archive '$backuparchive'"
6f74ef
-        return
6f74ef
-        ;;
6f74ef
-esac
6f74ef
-
6f74ef
-local backup_directory=$BUILD_DIR/outputfs/$NETFS_PREFIX
6f74ef
-
6f74ef
-# Normal (i.e. non-incremental/non-differential) backup:
6f74ef
-if ! test "incremental" = "$BACKUP_TYPE" -o "differential" = "$BACKUP_TYPE" ; then
6f74ef
-    # In case of normal (i.e. non-incremental) backup there is only one restore archive
6f74ef
-    # and its name is the same as the backup archive (usually 'backup.tar.gz'):
6f74ef
-    backuparchive="$backup_directory/$backup_file_name"
6f74ef
-    LogPrint "Using backup archive '$backuparchive'"
6f74ef
-    # This script is also run during "rear recover/restoreonly" where RESTORE_ARCHIVES must be set.
6f74ef
-    local backup_restore_workflows=( "recover" "restoreonly" )
6f74ef
-    if IsInArray $WORKFLOW ${backup_restore_workflows[@]} ; then
6f74ef
-        # Only set RESTORE_ARCHIVES the backup archive is actually accessible
6f74ef
-        # cf. https://github.com/rear/rear/issues/1166
6f74ef
-        if test -r "$backuparchive" ; then
6f74ef
-            RESTORE_ARCHIVES=( "$backuparchive" )
6f74ef
-        else
6f74ef
-            # In case of USB backup there is the subsequent 540_choose_backup_archive.sh script
6f74ef
-            # that shows a backup selection dialog when RESTORE_ARCHIVES is not already set.
6f74ef
-            if test "usb" = "$scheme" ; then
6f74ef
-                LogPrint "Backup archive '$backuparchive' not readable. Need to select another one."
6f74ef
-            else
6f74ef
-                Error "Backup archive '$backuparchive' not readable."
6f74ef
-            fi
6f74ef
-        fi
6f74ef
-    fi
6f74ef
-    return
6f74ef
-fi
6f74ef
-
6f74ef
-# Incremental or differential backup:
6f74ef
-set -e -u -o pipefail
6f74ef
-# Incremental or differential backup only works for the NETFS backup method
6f74ef
-# and only with the 'tar' backup program:
6f74ef
-if ! test "NETFS" = "$BACKUP" -a "tar" = "$BACKUP_PROG" ; then
6f74ef
-    Error "BACKUP_TYPE incremental or differential only works with BACKUP=NETFS and BACKUP_PROG=tar"
6f74ef
-fi
6f74ef
-# Incremental or differential backup is currently only known to work with BACKUP_URL=nfs://.
6f74ef
-# Other BACKUP_URL schemes may work and at least BACKUP_URL=usb:///... needs special setup
6f74ef
-# to work with incremental or differential backup (see https://github.com/rear/rear/issues/1145):
6f74ef
-if test "usb" = "$scheme" ; then
6f74ef
-    # When USB_SUFFIX is set the compliance mode is used where
6f74ef
-    # backup on USB works in compliance with backup on NFS which means
6f74ef
-    # a fixed backup directory where incremental or differential backups work.
6f74ef
-    # Use plain $USB_SUFFIX and not "$USB_SUFFIX" because when USB_SUFFIX contains only blanks
6f74ef
-    # test "$USB_SUFFIX" would result true because test " " results true:
6f74ef
-    test $USB_SUFFIX || Error "BACKUP_TYPE incremental or differential requires USB_SUFFIX for BACKUP_URL=usb"
6f74ef
-fi
6f74ef
-# Incremental or differential backup and keeping old backup contradict each other (mutual exclusive)
6f74ef
-# so that NETFS_KEEP_OLD_BACKUP_COPY must not be 'true' in case of incremental or differential backup:
6f74ef
-if test "$NETFS_KEEP_OLD_BACKUP_COPY" ; then
6f74ef
-    NETFS_KEEP_OLD_BACKUP_COPY=""
6f74ef
-    LogPrint "Disabled NETFS_KEEP_OLD_BACKUP_COPY because BACKUP_TYPE incremental or differential does not work with that"
6f74ef
-fi
6f74ef
-# For incremental or differential backup some date values (weekday, YYYY-MM-DD, HHMM) are needed
6f74ef
-# that must be consistent for one single point of the current time which means
6f74ef
-# one cannot call the 'date' command several times because then there would be
6f74ef
-# a small probability that e.g. weekday, YYYY-MM-DD, HHMM do not match
6f74ef
-# one single point in time (in particular when midnight passes in between).
6f74ef
-# Therefore the output of one single 'date' call is storend in an array and
6f74ef
-# the array elements are then assinged to individual variables as needed:
6f74ef
-local current_date_output=( $( date '+%a %Y-%m-%d %H%M' ) )
6f74ef
-local current_weekday="${current_date_output[0]}"
6f74ef
-local current_yyyy_mm_dd="${current_date_output[1]}"
6f74ef
-local current_hhmm="${current_date_output[2]}"
6f74ef
-# The date FULLBACKUP_OUTDATED_DAYS ago is needed to check if the latest full backup is too old.
6f74ef
-# When the latest full backup is more than FULLBACKUP_OUTDATED_DAYS ago a new full backup is made.
6f74ef
-# This separated call of the 'date' command which is technically needed because it is
6f74ef
-# for another point in time (e.g. 7 days ago) is run after the above call of the 'date'
6f74ef
-# command for the current time to be on the safe side when midnight passes in between
6f74ef
-# both 'date' commands which would then result that a new full backup is made
6f74ef
-# when the latest full backup is basically right now FULLBACKUP_OUTDATED_DAYS ago because
6f74ef
-# the stored date of the latest full backup is the current date at the time when it was made.
6f74ef
-# Example (assuming FULLBACKUP_OUTDATED_DAYS=7 ):
6f74ef
-# The latest full backup was made on Sunday January 10 in 2016 (just before midnight).
6f74ef
-# One week later this script runs again while midnight passes between the two 'date' calls
6f74ef
-# so that current_date_output[@]="Sun 2016-01-17 0000" (still Sunday January 17 in 2016)
6f74ef
-# and yyyymmdd_max_days_ago=20160111 (already Monday January 11 in 2016), then
6f74ef
-# Sunday January 10 is older than Monday January 11 so that a new full backup is made:
6f74ef
-test "$FULLBACKUP_OUTDATED_DAYS" || FULLBACKUP_OUTDATED_DAYS="7"
6f74ef
-local yyyymmdd_max_days_ago=$( date '+%Y%m%d' --date="$FULLBACKUP_OUTDATED_DAYS days ago" )
6f74ef
-# Full backup file names are of the form YYYY-MM-DD-HHMM-F.tar.gz
6f74ef
-# where the 'F' denotes a full backup:
6f74ef
-local full_backup_marker="F"
6f74ef
-# Incremental backup file names are of the form YYYY-MM-DD-HHMM-I.tar.gz
6f74ef
-# where the 'I' denotes an incremental backup:
6f74ef
-local incremental_backup_marker="I"
6f74ef
-# Differential backup file names are of the form YYYY-MM-DD-HHMM-D.tar.gz
6f74ef
-# where the last 'D' denotes a differential backup:
6f74ef
-local differential_backup_marker="D"
6f74ef
-# In case of incremental or differential backup the RESTORE_ARCHIVES contains
6f74ef
-# first the latest full backup file.
6f74ef
-# In case of incremental backup the RESTORE_ARCHIVES contains
6f74ef
-# after the latest full backup file each incremental backup
6f74ef
-# in the ordering how they must be restored.
6f74ef
-# For example when the latest full backup was made on Sunday
6f74ef
-# plus each subsequent weekday a separated incremental backup was made,
6f74ef
-# then during a "rear recover" on Wednesday morning
6f74ef
-# first the full backup from Sunday has to be restored,
6f74ef
-# then the incremental backup from Monday, and
6f74ef
-# finally the incremental backup from Tuesday.
6f74ef
-# In case of differential backup the RESTORE_ARCHIVES contains
6f74ef
-# after the latest full backup file the latest differential backup.
6f74ef
-# For example when the latest full backup was made on Sunday
6f74ef
-# plus each subsequent weekday a separated differential backup was made,
6f74ef
-# then during a "rear recover" on Wednesday morning
6f74ef
-# first the full backup from Sunday has to be restored,
6f74ef
-# and finally the differential backup from Tuesday
6f74ef
-# (i.e. the differential backup from Monday is skipped).
6f74ef
-# The date format YYYY-MM-DD that is used here is crucial.
6f74ef
-# It is the ISO 8601 format 'year-month-day' to specify a day of a year
6f74ef
-# that is accepted by 'tar' for the '--newer' option,
6f74ef
-# see the GNU tar manual section "Operating Only on New Files"
6f74ef
-# at https://www.gnu.org/software/tar/manual/html_node/after.html
6f74ef
-# and the GNU tar manual section "Calendar date items"
6f74ef
-# at https://www.gnu.org/software/tar/manual/html_node/Calendar-date-items.html#SEC124
6f74ef
-local date_glob_regex="[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]"
6f74ef
-local date_time_glob_regex="$date_glob_regex-[0-9][0-9][0-9][0-9]"
6f74ef
-# Determine what kind of backup must be created, 'full' or 'incremental' or 'differential'
6f74ef
-# (the empty default means it is undecided what kind of backup must be created):
6f74ef
-local create_backup_type=""
6f74ef
-# Code regarding creating a backup is useless during "rear recover" and
6f74ef
-# messages about creating a backup are misleading during "rear recover":
6f74ef
-local recovery_workflows=( "recover" "layoutonly" "restoreonly" )
6f74ef
-if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-    # When today is a specified full backup day, do a full backup in any case
6f74ef
-    # (regardless if there is already a full backup of this day):
6f74ef
-    if IsInArray "$current_weekday" "${FULLBACKUPDAY[@]}" ; then
6f74ef
-        create_backup_type="full"
6f74ef
-        LogPrint "Today's weekday ('$current_weekday') is a full backup day that triggers a new full backup in any case"
6f74ef
-    fi
6f74ef
-fi
6f74ef
-# Get the latest full backup (if exists):
6f74ef
-local full_backup_glob_regex="$date_time_glob_regex-$full_backup_marker$backup_file_suffix"
6f74ef
-# Here things like 'find /path/to/dir -name '*.tar.gz' | sort' are used because
6f74ef
-# one cannot use bash globbing via commands like 'ls /path/to/dir/*.tar.gz'
6f74ef
-# because /usr/sbin/rear sets the nullglob bash option which leads to plain 'ls'
6f74ef
-# when '/path/to/dir/*.tar.gz' matches nothing (i.e. when no backup file exists)
6f74ef
-# so that then plain 'ls' would result nonsense.
6f74ef
-local latest_full_backup=$( find $backup_directory -name "$full_backup_glob_regex" | sort | tail -n1 )
6f74ef
-# A latest full backup is found:
6f74ef
-if test "$latest_full_backup" ; then
6f74ef
-    local latest_full_backup_file_name=$( basename "$latest_full_backup" )
6f74ef
-    # The full_or_incremental_backup_glob_regex is also needed below for non-"recover" WORKFLOWs
6f74ef
-    # to set the right variables for creating an incremental backup:
6f74ef
-    local full_or_incremental_backup_glob_regex="$date_time_glob_regex-[$full_backup_marker$incremental_backup_marker]$backup_file_suffix"
6f74ef
-    # Code regarding creating a backup is useless during "rear recover" and
6f74ef
-    # messages about creating a backup are misleading during "rear recover":
6f74ef
-    if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-        # There is nothing to do here if it is already decided that
6f74ef
-        # a full backup must be created (see "full backup day" above"):
6f74ef
-        if ! test "full" = "$create_backup_type" ; then
6f74ef
-            local latest_full_backup_date=$( echo $latest_full_backup_file_name | grep -o "$date_glob_regex" )
6f74ef
-            local yyyymmdd_latest_full_backup=$( echo $latest_full_backup_date | tr -d '-' )
6f74ef
-            # Check if the latest full backup is too old:
6f74ef
-            if test $yyyymmdd_latest_full_backup -lt $yyyymmdd_max_days_ago ; then
6f74ef
-                create_backup_type="full"
6f74ef
-                LogPrint "Latest full backup date '$latest_full_backup_date' too old (more than $FULLBACKUP_OUTDATED_DAYS days ago) triggers new full backup"
6f74ef
-            else
6f74ef
-                # When a latest full backup is found that is not too old
6f74ef
-                # a BACKUP_TYPE (incremental or differential) backup will be created:
6f74ef
-                create_backup_type="$BACKUP_TYPE"
6f74ef
-                LogPrint "Latest full backup found ($latest_full_backup_file_name) triggers $BACKUP_TYPE backup"
6f74ef
-            fi
6f74ef
-        fi
6f74ef
-    else
6f74ef
-        # This script is also run during "rear recover" where RESTORE_ARCHIVES must be set:
6f74ef
-        case "$BACKUP_TYPE" in
6f74ef
-            (incremental)
6f74ef
-                # When a latest full backup is found use that plus all later incremental backups for restore:
6f74ef
-                # The following command is a bit tricky:
6f74ef
-                # It lists all YYYY-MM-DD-HHMM-F.tar.gz and all YYYY-MM-DD-HHMM-I.tar.gz files in the backup directory and sorts them
6f74ef
-                # and finally it outputs only those that match the latest full backup file name and incremental backups that got sorted after that
6f74ef
-                # where it is mandatory that the backup file names sort by date (i.e. date must be the leading part of the backup file names):
6f74ef
-                RESTORE_ARCHIVES=( $( find $backup_directory -name "$full_or_incremental_backup_glob_regex" | sort | sed -n -e "/$latest_full_backup_file_name/,\$p" ) )
6f74ef
-                ;;
6f74ef
-            (differential)
6f74ef
-                # For differential backup use the latest full backup plus the one latest differential backup for restore:
6f74ef
-                # The following command is a bit tricky:
6f74ef
-                # It lists all YYYY-MM-DD-HHMM-F.tar.gz and all YYYY-MM-DD-HHMM-D.tar.gz files in the backup directory and sorts them
6f74ef
-                # then it outputs only those that match the latest full backup file name and all differential backups that got sorted after that
6f74ef
-                # and then it outputs only the first line (i.e. the full backup) and the last line (i.e. the latest differential backup)
6f74ef
-                # but when no differential backup exists (i.e. when only the full backup exists) the first line is also the last line
6f74ef
-                # so that "sed -n -e '1p;$p'" outputs the full backup twice which is corrected by the final "sort -u":
6f74ef
-                local full_or_differential_backup_glob_regex="$date_time_glob_regex-[$full_backup_marker$differential_backup_marker]$backup_file_suffix"
6f74ef
-                RESTORE_ARCHIVES=( $( find $backup_directory -name "$full_or_differential_backup_glob_regex" | sort | sed -n -e "/$latest_full_backup_file_name/,\$p" | sed -n -e '1p;$p' | sort -u ) )
6f74ef
-                ;;
6f74ef
-            (*)
6f74ef
-                BugError "Unexpected BACKUP_TYPE '$BACKUP_TYPE'"
6f74ef
-                ;;
6f74ef
-        esac
6f74ef
-        # Tell the user what will be restored:
6f74ef
-        local restore_archives_file_names=""
6f74ef
-        for restore_archive in "${RESTORE_ARCHIVES[@]}" ; do
6f74ef
-            restore_archives_file_names="$restore_archives_file_names $( basename "$restore_archive" )"
6f74ef
-        done
6f74ef
-        LogPrint "For backup restore using $restore_archives_file_names"
6f74ef
-    fi
6f74ef
-# No latest full backup is found:
6f74ef
-else
6f74ef
-    # Code regarding creating a backup is useless during "rear recover" and
6f74ef
-    # messages about creating a backup are misleading during "rear recover":
6f74ef
-    if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-        # If no latest full backup is found create one during "rear mkbackup":
6f74ef
-        create_backup_type="full"
6f74ef
-        LogPrint "No full backup found (YYYY-MM-DD-HHMM-F.tar.gz) triggers full backup"
6f74ef
-    else
6f74ef
-        # This script is also run during "rear recover" where RESTORE_ARCHIVES must be set:
6f74ef
-        # If no latest full backup is found (i.e. no file name matches the YYYY-MM-DD-HHMM-F.tar.gz form)
6f74ef
-        # fall back to what is done in case of normal (i.e. non-incremental/non-differential) backup
6f74ef
-        # and hope for the best (i.e. that a backup_directory/backup_file_name actually exists).
6f74ef
-        # In case of normal (i.e. non-incremental/non-differential) backup there is only one restore archive
6f74ef
-        # and its name is the same as the backup archive (usually 'backup.tar.gz').
6f74ef
-        # This is only a fallback setting to be more on the safe side for "rear recover".
6f74ef
-        # Initially for the very fist run of incremental backup during "rear mkbackup"
6f74ef
-        # a full backup file of the YYYY-MM-DD-HHMM-F.tar.gz form will be created.
6f74ef
-        RESTORE_ARCHIVES=( "$backup_directory/$backup_file_name" )
6f74ef
-        LogPrint "Using $backup_file_name for backup restore"
6f74ef
-    fi
6f74ef
-fi
6f74ef
-# Code regarding creating a backup is useless during "rear recover" and
6f74ef
-# messages about creating a backup are misleading during "rear recover":
6f74ef
-if ! IsInArray $WORKFLOW ${recovery_workflows[@]} ; then
6f74ef
-    # Set the right variables for creating a backup (but do not actually do anything at this point):
6f74ef
-    case "$create_backup_type" in
6f74ef
-        (full)
6f74ef
-            local new_full_backup_file_name="$current_yyyy_mm_dd-$current_hhmm-$full_backup_marker$backup_file_suffix"
6f74ef
-            backuparchive="$backup_directory/$new_full_backup_file_name"
6f74ef
-            BACKUP_PROG_CREATE_NEWER_OPTIONS="-V $new_full_backup_file_name"
6f74ef
-            LogPrint "Performing full backup using backup archive '$new_full_backup_file_name'"
6f74ef
-            ;;
6f74ef
-        (incremental)
6f74ef
-            local new_incremental_backup_file_name="$current_yyyy_mm_dd-$current_hhmm-$incremental_backup_marker$backup_file_suffix"
6f74ef
-            backuparchive="$backup_directory/$new_incremental_backup_file_name"
6f74ef
-            # Get the latest latest incremental backup that is based on the latest full backup (if exists):
6f74ef
-            local incremental_backup_glob_regex="$date_time_glob_regex-$incremental_backup_marker$backup_file_suffix"
6f74ef
-            # First get the latest full backup plus all later incremental backups (cf. how RESTORE_ARCHIVES is set in case of incremental backup)
6f74ef
-            # then grep only the incremental backups and from the incremental backups use only the last one (if exists):
6f74ef
-            local latest_incremental_backup=$( find $backup_directory -name "$full_or_incremental_backup_glob_regex" | sort | sed -n -e "/$latest_full_backup_file_name/,\$p" | grep "$incremental_backup_glob_regex" | tail -n1 )
6f74ef
-            if test "$latest_incremental_backup" ; then
6f74ef
-                # A latest incremental backup that is based on the latest full backup is found:
6f74ef
-                local latest_incremental_backup_file_name=$( basename $latest_incremental_backup )
6f74ef
-                LogPrint "Latest incremental backup found ($latest_incremental_backup_file_name) that is newer than the latest full backup"
6f74ef
-                local latest_incremental_backup_date=$( echo $latest_incremental_backup_file_name | grep -o "$date_glob_regex" )
6f74ef
-                BACKUP_PROG_CREATE_NEWER_OPTIONS="--newer=$latest_incremental_backup_date -V $latest_incremental_backup_file_name"
6f74ef
-                LogPrint "Performing incremental backup for files newer than $latest_incremental_backup_date using backup archive '$new_incremental_backup_file_name'"
6f74ef
-            else
6f74ef
-                # When there is not yet an incremental backup that is based on the latest full backup
6f74ef
-                # the new created incremental backup must be based on the latest full backup:
6f74ef
-                BACKUP_PROG_CREATE_NEWER_OPTIONS="--newer=$latest_full_backup_date -V $latest_full_backup_file_name"
6f74ef
-                LogPrint "Performing incremental backup for files newer than $latest_full_backup_date using backup archive '$new_incremental_backup_file_name'"
6f74ef
-            fi
6f74ef
-            ;;
6f74ef
-        (differential)
6f74ef
-            local new_differential_backup_file_name="$current_yyyy_mm_dd-$current_hhmm-$differential_backup_marker$backup_file_suffix"
6f74ef
-            backuparchive="$backup_directory/$new_differential_backup_file_name"
6f74ef
-            BACKUP_PROG_CREATE_NEWER_OPTIONS="--newer=$latest_full_backup_date -V $latest_full_backup_file_name"
6f74ef
-            LogPrint "Performing differential backup for files newer than $latest_full_backup_date using backup archive '$new_differential_backup_file_name'"
6f74ef
-            ;;
6f74ef
-        (*)
6f74ef
-            BugError "Unexpected create_backup_type '$create_backup_type'"
6f74ef
-            ;;
6f74ef
-    esac
6f74ef
-fi
6f74ef
-# Go back from "set -e -u -o pipefail" to the defaults:
6f74ef
-apply_bash_flags_and_options_commands "$DEFAULT_BASH_FLAGS_AND_OPTIONS_COMMANDS"
6f74ef
-
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/070_set_backup_archive.sh b/usr/share/rear/verify/YUM/default/070_set_backup_archive.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..b8de3d9e
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/verify/YUM/default/070_set_backup_archive.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../../prep/YUM/default/070_set_backup_archive.sh
6f74ef
\ No newline at end of file
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/980_umount_YUM_dir.sh b/usr/share/rear/verify/YUM/default/980_umount_YUM_dir.sh
6f74ef
deleted file mode 100644
6f74ef
index dc719e38..00000000
6f74ef
--- a/usr/share/rear/verify/YUM/default/980_umount_YUM_dir.sh
6f74ef
+++ /dev/null
6f74ef
@@ -1,14 +0,0 @@
6f74ef
-# Copied from ../../../backup/NETFS/default/980_umount_NETFS_dir.sh for YUM
6f74ef
-# umount NETFS mountpoint
6f74ef
-
6f74ef
-if [[ "$BACKUP_UMOUNTCMD" ]] ; then
6f74ef
-    BACKUP_URL="var://BACKUP_UMOUNTCMD"
6f74ef
-fi
6f74ef
-
6f74ef
-umount_url $BACKUP_URL $BUILD_DIR/outputfs
6f74ef
-
6f74ef
-rmdir $v $BUILD_DIR/outputfs >&2
6f74ef
-if [[ $? -eq 0 ]] ; then
6f74ef
-    # the argument to RemoveExitTask has to be identical to the one given to AddExitTask
6f74ef
-    RemoveExitTask "rmdir $v $BUILD_DIR/outputfs >&2"
6f74ef
-fi
6f74ef
diff --git a/usr/share/rear/verify/YUM/default/980_umount_YUM_dir.sh b/usr/share/rear/verify/YUM/default/980_umount_YUM_dir.sh
6f74ef
new file mode 120000
6f74ef
index 00000000..ada5ea50
6f74ef
--- /dev/null
6f74ef
+++ b/usr/share/rear/verify/YUM/default/980_umount_YUM_dir.sh
6f74ef
@@ -0,0 +1 @@
6f74ef
+../../../restore/YUM/default/980_umount_YUM_dir.sh
6f74ef
\ No newline at end of file