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