Compare commits

...

No commits in common. "c8" and "c9-beta" have entirely different histories.
c8 ... c9-beta

22 changed files with 3811 additions and 942 deletions

1
.rear.metadata Normal file
View File

@ -0,0 +1 @@
13c23ad59254438ffcd0cde6400fd991cbfe194e SOURCES/rear-2.6.tar.gz

View File

@ -0,0 +1,47 @@
From df5e18b8d7c8359b48bc133bfa29734934d18160 Mon Sep 17 00:00:00 2001
From: Johannes Meixner <jsmeix@suse.com>
Date: Mon, 10 Aug 2020 16:20:38 +0200
Subject: [PATCH] Merge pull request #2469 from
rear/skip-kernel-builtin-modules-issue2414
In 400_copy_modules.sh skip copying kernel modules that are builtin modules.
The new behaviour is that when modules are listed in modules.builtin
and are also shown by modinfo then those modules are now skipped.
Before for such modules the modules file(s) would have been included
in the recovery system.
See https://github.com/rear/rear/issues/2414
---
usr/share/rear/build/GNU/Linux/400_copy_modules.sh | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/usr/share/rear/build/GNU/Linux/400_copy_modules.sh b/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
index d8d733d2..641b7f83 100644
--- a/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
+++ b/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
@@ -133,8 +133,13 @@ for dummy in "once" ; do
module=${module#.o}
# Strip trailing ".ko" if there:
module=${module#.ko}
- # Continue with the next module if the current one does not exist:
+ # Continue with the next module if the current one does not exist as a module file:
modinfo $module 1>/dev/null || continue
+ # Continue with the next module if the current one is a kernel builtin module
+ # cf. https://github.com/rear/rear/issues/2414#issuecomment-668632798
+ # Quoting the grep search value is mandatory here ($module might be empty or blank),
+ # cf. "Beware of the emptiness" in https://github.com/rear/rear/wiki/Coding-Style
+ grep -q "$( echo $module | tr '_-' '..' )" /lib/modules/$KERNEL_VERSION/modules.builtin && continue
# Resolve module dependencies:
# Get the module file plus the module files of other needed modules.
# This is currently only a "best effort" attempt because
@@ -166,7 +171,10 @@ done
# Remove those modules that are specified in the EXCLUDE_MODULES array:
for exclude_module in "${EXCLUDE_MODULES[@]}" ; do
- # Continue with the next module if the current one does not exist:
+ # Continue with the next module only if the current one does not exist as a module file
+ # but do not continue with the next module if the current one is a kernel builtin module
+ # so when a module file exists that gets removed regardless if it is also a builtin module
+ # cf. https://github.com/rear/rear/issues/2414#issuecomment-669115481
modinfo $exclude_module 1>/dev/null || continue
# In this case it is ignored when a module exists but 'modinfo -F filename' cannot show its filename
# because then it is assumed that also no module file had been copied above:

View File

@ -1,36 +0,0 @@
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
new file mode 100644
index 00000000..dba1e526
--- /dev/null
+++ b/usr/share/rear/output/PXE/default/820_copy_to_net.sh
@@ -0,0 +1,30 @@
+
+# 820_copy_to_net.sh
+
+# Check if we have a target location OUTPUT_URL
+test "$OUTPUT_URL" || return 0
+
+local scheme=$( url_scheme $OUTPUT_URL )
+local result_file=""
+local path=""
+
+case "$scheme" in
+ (nfs|cifs|usb|tape|file|davfs)
+ # The ISO has already been transferred by NETFS.
+ return 0
+ ;;
+ (fish|ftp|ftps|hftp|http|https|sftp)
+ # output/default/950_copy_result_files.sh will transfer them
+ return 0
+ ;;
+ (rsync)
+ LogPrint "Transferring PXE files to $OUTPUT_URL"
+ for result_file in "${RESULT_FILES[@]}" ; do
+ LogPrint "Transferring file: $result_file"
+ rsync -a $v "$result_file" "$OUTPUT_URL" || Error "Problem transferring '$result_file' to $OUTPUT_URL"
+ done
+ ;;
+ (*) Error "Invalid scheme '$scheme' in '$OUTPUT_URL'."
+ ;;
+esac
+

View File

@ -1,584 +0,0 @@
diff --git a/doc/user-guide/12-BLOCKCLONE.adoc b/doc/user-guide/12-BLOCKCLONE.adoc
index 061f0f49..2d4e0ed1 100644
--- a/doc/user-guide/12-BLOCKCLONE.adoc
+++ b/doc/user-guide/12-BLOCKCLONE.adoc
@@ -40,17 +40,17 @@ First we need to set some global options in _local.conf_,
In our small example backups will be stored in _/mnt/rear_ directory
on BACKUP_URL NFS server.
-```
+--------------------------
# cat local.conf
OUTPUT=ISO
BACKUP=NETFS
BACKUP_OPTIONS="nfsvers=3,nolock"
BACKUP_URL=nfs://<hostname>/mnt/rear
-```
+--------------------------
Now we will define variables that will apply only for targeted block device
-```
+--------------------------
# cat alien.conf
BACKUP=BLOCKCLONE # Define BLOCKCLONE as backup method
BACKUP_PROG_ARCHIVE="alien" # Name of image file
@@ -66,16 +66,16 @@ BLOCKCLONE_MBR_FILE="alien_boot_strap.img" # Output filename for b
BLOCKCLONE_PARTITIONS_CONF_FILE="alien_partitions.conf" # Output filename for partition configuration
BLOCKCLONE_ALLOW_MOUNTED="yes" # Device can be mounted during backup (default NO)
-```
+--------------------------
==== Running backup
Save partitions configuration, bootstrap code and create actual backup of /dev/sdc1
-```
+--------------------------
# rear -C alien mkbackuponly
-```
+--------------------------
==== Running restore from ReaR restore/recovery system
-```
+--------------------------
# rear -C alien restoreonly
Restore alien.dd.img to device: [/dev/sdc1] # User is always prompted for restore destination
Device /dev/sdc1 was not found. # If destination does not exist ReaR will try to create it (or fail if BLOCKCLONE_SAVE_MBR_DEV was not set during backup)
@@ -102,7 +102,7 @@ Device Boot Start End Sectors Size Id Type
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
-```
+--------------------------
==== Summary
In first example we have run backup of /dev/sdc1 partition and stored it on NFS
@@ -127,37 +127,37 @@ In next example we will do backup/restore using BLOCKCLONE and `ntfsclone`
of Linux (installed on /dev/sda) and Windows 10 (installed on /dev/sdb).
TIP: You can locate right disk devices using `df` and `os-prober`
-```
+--------------------------
# df -h /boot
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 10G 4.9G 5.2G 49% / # Linux is most probably installed on /dev/sda
# os-prober
/dev/sdb1:Windows 10 (loader):Windows:chain # Windows 10 is most probably installed on /dev/sdb
-```
+--------------------------
First we will configure some ReaR backup global options
(similar to link:12-BLOCKCLONE.adoc#1-backuprestore-of-arbitrary-block-device-with-blockclone-and-dd-on-nfs-server[first example]
we will do backup/restore with help of NFS server).
-```
+--------------------------
# cat local.conf
OUTPUT=ISO
BACKUP=NETFS
BACKUP_OPTIONS="nfsvers=3,nolock"
BACKUP_URL=nfs://<hostname>/mnt/rear
REQUIRED_PROGS+=( ntfsclone )
-```
+--------------------------
Now we will define backup parameters for Linux.
-```
+--------------------------
# cat base_os.conf
this_file_name=$( basename ${BASH_SOURCE[0]} )
LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
BACKUP_PROG_EXCLUDE+=( '/media/*' )
-```
+--------------------------
Our Windows 10 is by default installed on two separate partitions
(partition 1 for boot data and partition 2 for disk C:),
@@ -165,7 +165,7 @@ Our Windows 10 is by default installed on two separate partitions
Windows boot partition:
-```
+--------------------------
# cat windows_boot.conf
BACKUP=BLOCKCLONE
BACKUP_PROG_ARCHIVE="windows_boot"
@@ -179,10 +179,10 @@ BLOCKCLONE_PROG_OPTS="--quiet"
BLOCKCLONE_SAVE_MBR_DEV="/dev/sdb"
BLOCKCLONE_MBR_FILE="windows_boot_strap.img"
BLOCKCLONE_PARTITIONS_CONF_FILE="windows_partitions.conf"
-```
+--------------------------
Windows data partition (disk C:\):
-```
+--------------------------
# cat windows_data.conf
BACKUP=BLOCKCLONE
BACKUP_PROG_ARCHIVE="windows_data"
@@ -196,35 +196,35 @@ BLOCKCLONE_PROG_OPTS="--quiet"
BLOCKCLONE_SAVE_MBR_DEV="/dev/sdb"
BLOCKCLONE_MBR_FILE="windows_boot_strap.img"
BLOCKCLONE_PARTITIONS_CONF_FILE="windows_partitions.conf"
-```
+--------------------------
==== Running backup
First we will create backup of Linux. `mkbackup` command will create bootable
ISO image with ReaR rescue/recovery system that will be later used for
booting broken system and consecutive recovery.
-```
+--------------------------
# rear -C base_os mkbackup
-```
+--------------------------
Now we create backup of Windows 10 boot partition. Command `mkbackuponly`
will ensure that only partition data and partition layout will be saved
(ReaR rescue/recovery system will not be created which is exactly what we want).
-```
+--------------------------
# rear -C windows_boot mkbackuponly
-```
+--------------------------
Similarly, we create backup of Windows 10 data partition (disk C:\)
-```
+--------------------------
# rear -C windows_data mkbackuponly
-```
+--------------------------
==== Running restore from ReaR restore/recovery system
As a first step after ReaR rescue/recovery system booted,
we will recover Linux. This step will recover all Linux file systems,
OS data and bootloader. Windows disk will remain untouched.
-```
+--------------------------
# rear -C base_os recover
-```
+--------------------------
In second step will recover Windows 10 boot partition. During this step ReaR
will detect that destination partition is not present and ask us for device
@@ -234,25 +234,25 @@ In second step will recover Windows 10 boot partition. During this step ReaR
partition(s) configuration (currently mounted under _/mnt/local_) will
remain untouched. Before starting Windows 10 recovery we should identify
right disk for recovery, as mentioned earlier disk size could be a good start.
-```
+--------------------------
# fdisk -l /dev/sdb
Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 sectors
-```
+--------------------------
_/dev/sdb_ looks to be right destination, so we can proceed with restore.
-```
+--------------------------
# rear -C windows_boot restoreonly
Restore windows_boot.img to device: [/dev/sdb1]
Device /dev/sdb1 was not found.
Restore partition layout to (^c to abort): [/dev/sdb]
Checking that no-one is using this disk right now ... OK
...
-```
+--------------------------
Last step is to recover Windows 10 OS data (C:\).
Partitions on _/dev/sdb_ were already created in previous step,
hence ReaR will skip prompt for restoring partition layout.
-```
+--------------------------
# rear -C windows_data restoreonly
Restore windows_data.img to device: [/dev/sdb2]
Ntfsclone image version: 10.1
@@ -263,7 +263,7 @@ Space in use : 9396 MB (27.8%)
Offset to image data : 56 (0x38) bytes
Restoring NTFS from image ...
...
-```
+--------------------------
At this stage Linux together with Windows 10 is successfully restored.
@@ -286,7 +286,7 @@ In this example we will do backup/restore using BLOCKCLONE and `ntfsclone`
Backups will be stored on NFS server.
First we set global ReaR options
-```
+--------------------------
# cat local.conf
OUTPUT=ISO
BACKUP=NETFS
@@ -300,23 +300,23 @@ BLOCKCLONE_SAVE_MBR_DEV="/dev/sda"
BLOCKCLONE_MBR_FILE="boot_strap.img"
BLOCKCLONE_PARTITIONS_CONF_FILE="partitions.conf"
-```
+--------------------------
IMPORTANT: BLOCKCLONE_STRICT_PARTITIONING is mandatory if backing up
Linux / Windows that shares one disk. Not using this option might result to
unbootable Windows 10 installation.
Linux configuration
-```
+--------------------------
# cat base_os.conf
this_file_name=$( basename ${BASH_SOURCE[0]} )
LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
BACKUP_PROG_EXCLUDE+=( '/media/*' )
-```
+--------------------------
Windows 10 boot partition configuration
-```
+--------------------------
# cat windows_boot.conf
BACKUP=BLOCKCLONE
@@ -328,10 +328,10 @@ BLOCKCLONE_PROG=ntfsclone
BLOCKCLONE_PROG_OPTS="--quiet"
BLOCKCLONE_SOURCE_DEV="/dev/sda1"
-```
+--------------------------
Windows 10 data partition configuration
-```
+--------------------------
# cat windows_data.conf
BACKUP=BLOCKCLONE
BACKUP_PROG_ARCHIVE="windows_data"
@@ -342,42 +342,42 @@ BLOCKCLONE_PROG=ntfsclone
BLOCKCLONE_PROG_OPTS="--quiet"
BLOCKCLONE_SOURCE_DEV="/dev/sda2"
-```
+--------------------------
==== Running backup
Backup of Linux
-```
+--------------------------
# rear -C base_os mkbackup
-```
+--------------------------
Backup of Windows 10 boot partition
-```
+--------------------------
# rear -C windows_boot mkbackuponly
-```
+--------------------------
Backup of Windows 10 data partition
-```
+--------------------------
# rear -C windows_data mkbackuponly
-```
+--------------------------
==== Running restore from ReaR restore/recovery system
Restore Linux
-```
+--------------------------
# rear -C base_os recover
-```
+--------------------------
During this step ReaR will also create both Windows 10 partitions
Restore Windows 10 data partition
-```
+--------------------------
# rear -C windows_data restoreonly
-```
+--------------------------
Restore Windows 10 boot partition
-```
+--------------------------
# rear -C windows_boot restoreonly
-```
+--------------------------
=== 4. Backup/restore of Linux / Windows 10 dual boot setup sharing same disk with USB as destination
@@ -389,7 +389,7 @@ In this example we will do backup/restore using BLOCKCLONE and `ntfsclone`
Backups will be stored on USB disk drive (_/dev/sdb_ in this example).
Global options
-```
+--------------------------
# cat local.conf
OUTPUT=USB
BACKUP=NETFS
@@ -407,10 +407,10 @@ BLOCKCLONE_SAVE_MBR_DEV="/dev/sda"
BLOCKCLONE_MBR_FILE="boot_strap.img"
BLOCKCLONE_PARTITIONS_CONF_FILE="partitions.conf"
-```
+--------------------------
Options used during Linux backup/restore.
-```
+--------------------------
# cat local.conf
OUTPUT=USB
BACKUP=NETFS
@@ -428,14 +428,14 @@ BLOCKCLONE_SAVE_MBR_DEV="/dev/sda"
BLOCKCLONE_MBR_FILE="boot_strap.img"
BLOCKCLONE_PARTITIONS_CONF_FILE="partitions.conf"
-```
+--------------------------
IMPORTANT: USB_SUFFIX option is mandatory as it avoids ReaR to hold every
backup in separate directory, this behavior is essential for BLOCKCLONE
backup method to work correctly.
Windows boot partition options
-```
+--------------------------
# cat windows_boot.conf
BACKUP=BLOCKCLONE
@@ -447,10 +447,10 @@ BLOCKCLONE_PROG=ntfsclone
BLOCKCLONE_PROG_OPTS="--quiet"
BLOCKCLONE_SOURCE_DEV="/dev/sda1"
-```
+--------------------------
Windows data partition options
-```
+--------------------------
# cat windows_data.conf
BACKUP=BLOCKCLONE
BACKUP_PROG_ARCHIVE="windows_data"
@@ -461,11 +461,11 @@ BLOCKCLONE_PROG=ntfsclone
BLOCKCLONE_PROG_OPTS="--quiet"
BLOCKCLONE_SOURCE_DEV="/dev/sda2"
-```
+--------------------------
==== Running backup
First we need to format target USB device, with `rear format` command
-```
+--------------------------
# rear -v format /dev/sdb
Relax-and-Recover 2.00 / Git
Using log file: /var/log/rear/rear-centosd.log
@@ -477,15 +477,15 @@ Creating ReaR data partition up to 100% of '/dev/sdb'
Setting 'boot' flag on /dev/sdb
Creating ext3 filesystem with label 'REAR-000' on '/dev/sdb1'
Adjusting filesystem parameters on '/dev/sdb1'
-```
+--------------------------
Backup of Linux
-```
+--------------------------
# rear -C base_os mkbackup
-```
+--------------------------
Backup of Windows 10 boot partition
-```
+--------------------------
# rear -C windows_boot mkbackuponly
NTFS volume version: 3.1
Cluster size : 4096 bytes
@@ -496,10 +496,10 @@ Accounting clusters ...
Space in use : 338 MB (64.4%)
Saving NTFS to image ...
Syncing ...
-```
+--------------------------
Backup of Windows 10 data partition
-```
+--------------------------
# rear -C windows_data mkbackuponly
NTFS volume version: 3.1
Cluster size : 4096 bytes
@@ -510,7 +510,7 @@ Accounting clusters ...
Space in use : 9833 MB (54.3%)
Saving NTFS to image ...
Syncing ...
-```
+--------------------------
==== Running restore from ReaR restore/recovery system
For sake of this demonstration I've purposely used ReaR's rescue/recovery media
@@ -519,7 +519,7 @@ For sake of this demonstration I've purposely used ReaR's rescue/recovery media
demonstrate possibility of ReaR to recover backup to arbitrary disk. +
As first step Linux will be restored, this will create all the partitions
needed, even those used by Windows 10.
-```
+--------------------------
RESCUE centosd:~ # rear -C base_os recover
Relax-and-Recover 2.00 / Git
Using log file: /var/log/rear/rear-centosd.log
@@ -541,13 +541,13 @@ Original disk /dev/sda does not exist in the target system. Please choose an app
2) /dev/sdb
3) Do not map disk.
#?
-```
+--------------------------
Now ReaR recover command stops as it detected that disk layout is not identical.
As our desired restore target is _/dev/sdb_ we choose right disk and continue
recovery. ReaR will ask to check created restore scripts, but this is not
needed in our scenario.
-```
+--------------------------
#? 2
2017-01-25 20:54:01 Disk /dev/sdb chosen as replacement for /dev/sda.
Disk /dev/sdb chosen as replacement for /dev/sda.
@@ -607,11 +607,11 @@ Skip installing GRUB Legacy boot loader because GRUB 2 is installed (grub-probe
Installing GRUB2 boot loader
Finished recovering your system. You can explore it under '/mnt/local'.
Saving /var/log/rear/rear-centosd.log as /var/log/rear/rear-centosd-recover-base_os.log
-```
+--------------------------
Now we have Linux part restored, GRUB installed and partitions created, hence
we can continue with Windows 10 boot partition recovery.
-```
+--------------------------
RESCUE centosd:~ # rear -C windows_boot restoreonly
Restore windows_boot.nc.img to device: [/dev/sda1] /dev/sdb1
Ntfsclone image version: 10.1
@@ -622,12 +622,12 @@ Space in use : 338 MB (64.4%)
Offset to image data : 56 (0x38) bytes
Restoring NTFS from image ...
Syncing ...
-```
+--------------------------
Similarly to Linux restore, we were prompted for restore destination, which
is /dev/sdb1 in our case. +
As the last step we will recover Windows 10 data partition
-```
+--------------------------
RESCUE centosd:~ # rear -C windows_data restoreonly
Restore windows_data.nc.img to device: [/dev/sda2] /dev/sdb2
Ntfsclone image version: 10.1
@@ -638,7 +638,7 @@ Space in use : 9867 MB (54.5%)
Offset to image data : 56 (0x38) bytes
Restoring NTFS from image ...
Syncing ...
-```
+--------------------------
Again after restoreonly command is launched, ReaR prompts for restore
destination. +
@@ -662,25 +662,25 @@ The _BLOCKCLONE_TRY_UNMOUNT_ is important here: it will attempt to unmount the
run the risk that the data may be inconsistent.
Global options
-```
+--------------------------
# cat site.conf
OUTPUT=ISO
KEEP_OLD_OUTPUT_COPY=1
BACKUP_URL="nfs://<hostname>/Stations_bkup/rear/"
-```
+--------------------------
Options used for the base OS backup:
-```
+--------------------------
# cat base_system.conf
this_file_name=$( basename ${BASH_SOURCE[0]} )
LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
BACKUP_PROG_EXCLUDE+=( '/products/*' )
BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
BACKUP=NETFS
-```
+--------------------------
Options used to take the encrypted filesystem image:
-```
+--------------------------
this_file_name=$( basename ${BASH_SOURCE[0]} )
LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
BACKUP=BLOCKCLONE
@@ -694,18 +694,18 @@ BLOCKCLONE_SOURCE_DEV="/dev/vg00/lvol4"
BLOCKCLONE_ALLOW_MOUNTED="yes"
BLOCKCLONE_TRY_UNMOUNT="yes"
-```
+--------------------------
==== Running backup
Base OS backup:
-```
+--------------------------
# rear -C base_system mkbackup
-```
+--------------------------
Create image of encrypted filesystem:
-```
+--------------------------
# rear -C products_backup mkbackuponly
-```
+--------------------------
==== Running restore from ReaR restore/recovery system
First recover the base OS. This will create all the partitions needed, including
@@ -713,7 +713,7 @@ First recover the base OS. This will create all the partitions needed, including
As illustrated below, you will be prompted to chose a new encryption passphrase.
Please provide one, but you need not care about its value as it will get overwritten
during the next phase:
-```
+--------------------------
RESCUE pc-pan:~ # rear -C base_system.conf recover
[...]
Please enter the password for LUKS device cr_vg00-lvol4 (/dev/mapper/vg00-lvol4):
@@ -724,7 +724,7 @@ Creating filesystem of type xfs with mount point /products on /dev/mapper/cr_vg0
Mounting filesystem /products
Disk layout created.
[...]
-```
+--------------------------
Now we can proceed and restore the encrypted filesystem image. The target filesystem
will have been mounted by ReaR during the previous phase, but this will be
@@ -732,12 +732,12 @@ Now we can proceed and restore the encrypted filesystem image. The target filesy
to "yes". +
As illustrated below, you will be prompted for the target block device to use.
Confirm by pressing Enter or type in another value:
-```
+--------------------------
RESCUE pc-pan:~ # rear -C products_backup.conf restoreonly
[...]
Restore backup-products_backup.dd.img to device: [/dev/vg00/lvol4]
[...]
-```
+--------------------------
Please note that the target device will not be re-mounted by the script at the end
of the restore phase. If needed, this should be done manually. +
diff --git a/doc/user-guide/16-Rubrik-CDM.adoc b/doc/user-guide/16-Rubrik-CDM.adoc
index 41f37d20..3ac23b7b 100644
--- a/doc/user-guide/16-Rubrik-CDM.adoc
+++ b/doc/user-guide/16-Rubrik-CDM.adoc
@@ -84,7 +84,7 @@ To make CentOS v8.0 work the following line was needed:
== Test Matrix
.Test Matrix
-[%header,format=csv]
+[options="header",format="csv"]
|===
Operating System,DHCP,Static IP,Virtual,Physical,LVM Root Disk,Plain Root Disk,EXT3,EXT4,XFS,BTRFS,Original Cluster,Replication Cluster
CentOS 7.3,,pass,Pass,,Pass,,,,Pass,,Pass,

View File

@ -0,0 +1,58 @@
commit 389e5026df575ad98695191044257cf2b33d565b
Author: pcahyna <pcahyna@users.noreply.github.com>
Date: Mon Jul 4 15:48:43 2022 +0200
Merge pull request #2825 from lzaoral/replace-mkinitrd-with-dracut
Replace `mkinitrd` with `dracut` on Fedora and RHEL
diff --git a/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh b/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh
index 3476b77f..f296e624 100644
--- a/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh
+++ b/usr/share/rear/finalize/Fedora/i386/550_rebuild_initramfs.sh
@@ -61,7 +61,7 @@ NEW_INITRD_MODULES=( $(tr " " "\n" <<< "${NEW_INITRD_MODULES[*]}" | sort | uniq
Log "New INITRD_MODULES='${OLD_INITRD_MODULES[@]} ${NEW_INITRD_MODULES[@]}'"
INITRD_MODULES="${OLD_INITRD_MODULES[@]} ${NEW_INITRD_MODULES[@]}"
-WITH_INITRD_MODULES=$( printf '%s\n' ${INITRD_MODULES[@]} | awk '{printf "--with=%s ", $1}' )
+WITH_INITRD_MODULES=$( printf '%s\n' ${INITRD_MODULES[@]} | awk '{printf "--add-drivers=%s ", $1}' )
# Recreate any initrd or initramfs image under $TARGET_FS_ROOT/boot/ with new drivers
# Images ignored:
@@ -76,19 +76,19 @@ for INITRD_IMG in $( ls $TARGET_FS_ROOT/boot/initramfs-*.img $TARGET_FS_ROOT/boo
# Do not use KERNEL_VERSION here because that is readonly in the rear main script:
kernel_version=$( basename $( echo $INITRD_IMG ) | cut -f2- -d"-" | sed s/"\.img"// )
INITRD=$( echo $INITRD_IMG | egrep -o "/boot/.*" )
- LogPrint "Running mkinitrd..."
- # Run mkinitrd directly in chroot without a login shell in between (see https://github.com/rear/rear/issues/862).
- # We need the mkinitrd binary in the chroot environment i.e. the mkinitrd binary in the recreated system.
- # Normally we would use a login shell like: chroot $TARGET_FS_ROOT /bin/bash --login -c 'type -P mkinitrd'
+ LogPrint "Running dracut..."
+ # Run dracut directly in chroot without a login shell in between (see https://github.com/rear/rear/issues/862).
+ # We need the dracut binary in the chroot environment i.e. the dracut binary in the recreated system.
+ # Normally we would use a login shell like: chroot $TARGET_FS_ROOT /bin/bash --login -c 'type -P dracut'
# because otherwise there is no useful PATH (PATH is only /bin) so that 'type -P' won't find it
# but we cannot use a login shell because that contradicts https://github.com/rear/rear/issues/862
# so that we use a plain (non-login) shell and set a (hopefully) reasonable PATH:
- local mkinitrd_binary=$( chroot $TARGET_FS_ROOT /bin/bash -c 'PATH=/sbin:/usr/sbin:/usr/bin:/bin type -P mkinitrd' )
- # If there is no mkinitrd in the chroot environment plain 'chroot $TARGET_FS_ROOT' will hang up endlessly
+ local dracut_binary=$( chroot $TARGET_FS_ROOT /bin/bash -c 'PATH=/sbin:/usr/sbin:/usr/bin:/bin type -P dracut' )
+ # If there is no dracut in the chroot environment plain 'chroot $TARGET_FS_ROOT' will hang up endlessly
# and then "rear recover" cannot be aborted with the usual [Ctrl]+[C] keys.
# Use plain $var because when var contains only blanks test "$var" results true because test " " results true:
- if test $mkinitrd_binary ; then
- if chroot $TARGET_FS_ROOT $mkinitrd_binary -v -f ${WITH_INITRD_MODULES[@]} $INITRD $kernel_version >&2 ; then
+ if test $dracut_binary ; then
+ if chroot $TARGET_FS_ROOT $dracut_binary -v -f ${WITH_INITRD_MODULES[@]} $INITRD $kernel_version >&2 ; then
LogPrint "Updated initrd with new drivers for kernel $kernel_version."
else
LogPrint "WARNING:
@@ -99,7 +99,7 @@ and decide yourself, whether the system will boot or not.
fi
else
LogPrint "WARNING:
-Cannot create initrd (found no mkinitrd in the recreated system).
+Cannot create initrd (found no dracut in the recreated system).
Check the recreated system (mounted at $TARGET_FS_ROOT)
and decide yourself, whether the system will boot or not.
"

View File

@ -0,0 +1,130 @@
commit b06d059108db9b0c46cba29cc174f60e129164f1
Author: Johannes Meixner <jsmeix@suse.com>
Date: Tue Mar 9 14:40:59 2021 +0100
Merge pull request #2580 from rear/jsmeix-load-nvram-module
In etc/scripts/system-setup.d/41-load-special-modules.sh
load the nvram kernel module if possible to make /dev/nvram appear
because /dev/nvram should be there when installing GRUB,
see https://github.com/rear/rear/issues/2554
and include the nvram kernel module in the recovery system
because nvram could be a module in particular on POWER architecture
see https://github.com/rear/rear/issues/2554#issuecomment-764720180
diff --git a/usr/share/rear/build/GNU/Linux/400_copy_modules.sh b/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
index d8d733d2..a0ca9084 100644
--- a/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
+++ b/usr/share/rear/build/GNU/Linux/400_copy_modules.sh
@@ -116,8 +116,12 @@ for dummy in "once" ; do
# As a way out of this dilemma we add the below listed modules no longer via conf/GNU/Linux.conf
# but here after the user config files were sourced so that now the user can specify
# MODULES=( 'moduleX' 'moduleY' ) in etc/rear/local.conf to get additional kernel modules
- # included in the recovery system in addition to the ones via an empty MODULES=() setting:
- MODULES+=( vfat
+ # included in the recovery system in addition to the ones via an empty MODULES=() setting.
+ # nvram could be a module in particular on POWER architecture,
+ # cf. https://github.com/rear/rear/issues/2554#issuecomment-764720180
+ # and https://github.com/rear/rear/pull/2580#issuecomment-791344794
+ MODULES+=( nvram
+ vfat
nls_iso8859_1 nls_utf8 nls_cp437
af_packet
unix
diff --git a/usr/share/rear/finalize/Linux-ppc64le/660_install_grub2.sh b/usr/share/rear/finalize/Linux-ppc64le/660_install_grub2.sh
index 4c2698f3..0cb3ee41 100644
--- a/usr/share/rear/finalize/Linux-ppc64le/660_install_grub2.sh
+++ b/usr/share/rear/finalize/Linux-ppc64le/660_install_grub2.sh
@@ -104,9 +104,39 @@ fi
# Do not update nvram when system is running in PowerNV mode (BareMetal).
# grub2-install will fail if not run with the --no-nvram option on a PowerNV system,
# see https://github.com/rear/rear/pull/1742
-grub2_install_option=""
+grub2_no_nvram_option=""
if [[ $(awk '/platform/ {print $NF}' < /proc/cpuinfo) == PowerNV ]] ; then
- grub2_install_option="--no-nvram"
+ grub2_no_nvram_option="--no-nvram"
+fi
+# Also do not update nvram when no character device node /dev/nvram exists.
+# On POWER architecture the nvram kernel driver could be also built as a kernel module
+# that gets loaded via etc/scripts/system-setup.d/41-load-special-modules.sh
+# but whether or not the nvram kernel driver will then create /dev/nvram
+# depends on whether or not the hardware platform supports nvram.
+# I <jsmeix@suse.de> asked on a SUSE internal mailing list
+# and got the following reply (excerpts):
+# ----------------------------------------------------------------
+# > I would like to know when /dev/nvram exists and when not.
+# > I assume /dev/nvram gets created as other device nodes
+# > by the kernel (probably together with udev).
+# > I would like to know under what conditions /dev/nvram
+# > gets created and when it is not created.
+# > It seems on PPC /dev/nvram usually exist but sometimes not.
+# In case of powerpc, it gets created by nvram driver
+# (nvram_module_init) whenever the powerpc platform driver
+# has ppc_md.nvram_size greater than zero in it's machine
+# description structure.
+# How exactly ppc_md.nvram_size gets gets populated by platform
+# code depends on the platform, e.g. on most modern systems
+# it gets populated from 'nvram' device tree node
+# (and only if such node has #bytes > 0).
+# ----------------------------------------------------------------
+# So /dev/nvram may not exist regardless that the nvram kernel driver is there
+# and then grub2-install must be called with the '--no-nvram' option
+# because otherwise installing the bootloader fails
+# cf. https://github.com/rear/rear/issues/2554
+if ! test -c /dev/nvram ; then
+ grub2_no_nvram_option="--no-nvram"
fi
# When GRUB2_INSTALL_DEVICES is specified by the user
@@ -134,7 +164,7 @@ if test "$GRUB2_INSTALL_DEVICES" ; then
else
LogPrint "Installing GRUB2 on $grub2_install_device (specified in GRUB2_INSTALL_DEVICES)"
fi
- if ! chroot $TARGET_FS_ROOT /bin/bash --login -c "$grub_name-install $grub2_install_option $grub2_install_device" ; then
+ if ! chroot $TARGET_FS_ROOT /bin/bash --login -c "$grub_name-install $grub2_no_nvram_option $grub2_install_device" ; then
LogPrintError "Failed to install GRUB2 on $grub2_install_device"
grub2_install_failed="yes"
fi
@@ -170,7 +200,7 @@ for part in $part_list ; do
LogPrint "Found PPC PReP boot partition $part - installing GRUB2 there"
# Erase the first 512 bytes of the PPC PReP boot partition:
dd if=/dev/zero of=$part
- if chroot $TARGET_FS_ROOT /bin/bash --login -c "$grub_name-install $grub2_install_option $part" ; then
+ if chroot $TARGET_FS_ROOT /bin/bash --login -c "$grub_name-install $grub2_no_nvram_option $part" ; then
# In contrast to the above behaviour when GRUB2_INSTALL_DEVICES is specified
# consider it here as a successful bootloader installation when GRUB2
# got installed on at least one PPC PReP boot partition:
diff --git a/usr/share/rear/skel/default/etc/scripts/system-setup.d/41-load-special-modules.sh b/usr/share/rear/skel/default/etc/scripts/system-setup.d/41-load-special-modules.sh
index 9b0b3b8a..2e1d1912 100644
--- a/usr/share/rear/skel/default/etc/scripts/system-setup.d/41-load-special-modules.sh
+++ b/usr/share/rear/skel/default/etc/scripts/system-setup.d/41-load-special-modules.sh
@@ -1,6 +1,24 @@
-# some things are special
+# Special cases of kernel module loading.
-# XEN PV does not autoload some modules
-if [ -d /proc/xen ] ; then
- modprobe xenblk
+# XEN PV does not autoload some modules:
+test -d /proc/xen && modprobe xenblk
+
+# On POWER architecture the nvram kernel driver may be no longer built into the kernel
+# but nowadays it could be also built as a kernel module that needs to be loaded
+# cf. https://github.com/rear/rear/issues/2554#issuecomment-764720180
+# because normally grub2-install gets called without the '--no-nvram' option
+# e.g. see finalize/Linux-ppc64le/620_install_grub2.sh
+# which is how grub2-install should be called when the hardware supports nvram.
+# Nothing to do when the character device node /dev/nvram exists
+# because then the nvram kernel driver is already there:
+if ! test -c /dev/nvram ; then
+ # Nothing can be done when there is no nvram kernel module.
+ # Suppress the possible 'modprobe -n nvram' error message like
+ # "modprobe: FATAL: Module nvram not found in directory /lib/modules/..."
+ # to avoid a possible "FATAL" false alarm message that would appear
+ # on the user's terminal during recovery system startup
+ # cf. https://github.com/rear/rear/pull/2537#issuecomment-741825046
+ # but when there is a nvram kernel module show possible 'modprobe nvram'
+ # (error) messages on the user's terminal during recovery system startup:
+ modprobe -n nvram 2>/dev/null && modprobe nvram
fi

View File

@ -0,0 +1,37 @@
commit 2922b77e950537799fdadf5b3ebf6a05d97f6f2f
Author: pcahyna <pcahyna@users.noreply.github.com>
Date: Mon Jun 20 17:42:58 2022 +0200
Merge pull request #2822 from pcahyna/fix-vim-symlink
Fix vi in the rescue system on Fedora and RHEL 9
diff --git a/usr/share/rear/build/GNU/Linux/005_create_symlinks.sh b/usr/share/rear/build/GNU/Linux/005_create_symlinks.sh
index df75e07d..55f25bef 100644
--- a/usr/share/rear/build/GNU/Linux/005_create_symlinks.sh
+++ b/usr/share/rear/build/GNU/Linux/005_create_symlinks.sh
@@ -8,7 +8,6 @@
ln -sf $v bin/init $ROOTFS_DIR/init >&2
ln -sf $v bin $ROOTFS_DIR/sbin >&2
ln -sf $v bash $ROOTFS_DIR/bin/sh >&2
-ln -sf $v vi $ROOTFS_DIR/bin/vim >&2
ln -sf $v true $ROOTFS_DIR/bin/pam_console_apply >&2 # RH/Fedora with udev needs this
ln -sf $v ../bin $ROOTFS_DIR/usr/bin >&2
ln -sf $v ../bin $ROOTFS_DIR/usr/sbin >&2
diff --git a/usr/share/rear/conf/GNU/Linux.conf b/usr/share/rear/conf/GNU/Linux.conf
index 89aedd4c..0c97594a 100644
--- a/usr/share/rear/conf/GNU/Linux.conf
+++ b/usr/share/rear/conf/GNU/Linux.conf
@@ -206,6 +206,12 @@ LIBS+=(
)
COPY_AS_IS+=( /dev /etc/inputr[c] /etc/protocols /etc/services /etc/rpc /etc/termcap /etc/terminfo /lib*/terminfo /usr/share/terminfo /etc/netconfig /etc/mke2fs.conf /etc/*-release /etc/localtime /etc/magic /usr/share/misc/magic /etc/dracut.conf /etc/dracut.conf.d /usr/lib/dracut /sbin/modprobe.ksplice-orig /etc/sysctl.conf /etc/sysctl.d /etc/e2fsck.conf )
+
+# Needed by vi on Fedora and derived distributions
+# where vi is a shell script that executes /usr/libexec/vi
+# see https://github.com/rear/rear/pull/2822
+COPY_AS_IS+=( /usr/libexec/vi )
+
# Required by curl with https:
# There are stored the distribution provided certificates
# installed from packages, nothing confidential.

View File

@ -0,0 +1,18 @@
diff --git a/usr/share/rear/prep/GNU/Linux/220_include_lvm_tools.sh b/usr/share/rear/prep/GNU/Linux/220_include_lvm_tools.sh
index 4b73fb05..c7704032 100644
--- a/usr/share/rear/prep/GNU/Linux/220_include_lvm_tools.sh
+++ b/usr/share/rear/prep/GNU/Linux/220_include_lvm_tools.sh
@@ -8,6 +8,13 @@ PROGS+=( lvm dmsetup dmeventd fsadm )
COPY_AS_IS+=( /etc/lvm )
+# Workaround for a LVM segfault when creating a PV with an UUID already present
+# in the device file: omit the device file from the rescue system
+# https://bugzilla.redhat.com/show_bug.cgi?id=2117937
+# proper fix:
+# https://sourceware.org/git/?p=lvm2.git;a=commit;h=8c3cfc75c72696ae8b620555fcc4f815b0c1d6b6
+COPY_AS_IS_EXCLUDE+=( /etc/lvm/devices )
+
if lvs --noheadings -o thin_count | grep -q -v "^\s*$" ; then
# There are Thin Pools on the system, include required binaries
PROGS+=( thin_check )

View File

@ -0,0 +1,440 @@
diff --git a/usr/share/rear/rescue/NBU/default/460_prepare_netbackup_systemd.sh b/usr/share/rear/rescue/NBU/default/460_prepare_netbackup_systemd.sh
new file mode 100644
index 00000000..f7423e0a
--- /dev/null
+++ b/usr/share/rear/rescue/NBU/default/460_prepare_netbackup_systemd.sh
@@ -0,0 +1,41 @@
+# 460_prepare_netbackup_systemd.sh
+# prepare systemd units for NBU (only if NBU version >=7.x)
+
+# set in 450_prepare_netbackup.sh
+[[ $NBU_version -lt 7 ]] && return # NBU is using xinetd when version <7.x
+
+# Skip if systemd is not used.
+has_binary systemctl || return 0
+
+# Local functions that are 'unset' at the end of this script:
+
+function get_unit_path () {
+ systemctl show -P FragmentPath $1
+}
+
+function get_unit_dropin_paths () {
+ systemctl show -P DropInPaths $1
+}
+
+local unit_file_path
+local i
+local unit
+
+for unit in vxpbx_exchanged.service netbackup.service ; do
+ unit_file_path="$( get_unit_path $unit )"
+ if [ -n "$unit_file_path" ]; then
+ cp $v "$unit_file_path" $ROOTFS_DIR/etc/systemd/system
+ ln -s ../$unit $ROOTFS_DIR/etc/systemd/system/default.target.wants || Error "Failed to enable Netbackup service $unit in the rescue system"
+ Log "Enabled Netbackup service $unit in the rescue system"
+ for i in $( get_unit_dropin_paths $unit ) ; do
+ mkdir -p $ROOTFS_DIR/etc/systemd/system/$unit.d
+ cp $v $i $ROOTFS_DIR/etc/systemd/system/$unit.d
+ done
+ fi
+done
+
+# Local functions must be 'unset' because bash does not support 'local function ...'
+# cf. https://unix.stackexchange.com/questions/104755/how-can-i-create-a-local-function-in-my-bashrc
+unset -f get_unit_path
+unset -f get_unit_dropin_paths
+unset -f unit_is_enabled
diff --git a/usr/share/rear/skel/default/etc/scripts/run-automatic-rear b/usr/share/rear/skel/default/etc/scripts/run-automatic-rear
new file mode 100755
index 00000000..6edc657a
--- /dev/null
+++ b/usr/share/rear/skel/default/etc/scripts/run-automatic-rear
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+source /etc/scripts/system-setup-functions.sh
+
+# In debug mode run the automated 'rear recover' also with debug options.
+# Because the kernel command line option 'debug' means 'set -x' for the system setup scripts
+# it also means '-D' (i.e. 'set -x') for the automated 'rear recover' run:
+if rear_debug ; then
+ rear_debug_options='-D'
+else
+ rear_debug_options=''
+fi
+
+# Launch rear recover automatically:
+if automatic_recovery ; then
+ choices=( "View Relax-and-Recover log file(s)"
+ "Go to Relax-and-Recover shell"
+ )
+ echo -e "\nLaunching 'rear recover' automatically\n"
+ if rear $rear_debug_options recover ; then
+ echo -e "\n'rear recover' finished successfully\n"
+ choices+=( "Reboot" )
+ else
+ echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
+ fi
+ PS3="Select what to do "
+ select choice in "${choices[@]}" ; do
+ case "$REPLY" in
+ (1)
+ # Do not assume the ReaR log file is named rear-$HOSTNAME.log
+ # the user can have specified any name as LOGFILE:
+ less /var/log/rear/*
+ ;;
+ (2)
+ echo "" > /etc/issue
+ echo "" > /etc/motd
+ break
+ ;;
+ (3)
+ reboot
+ ;;
+ esac
+ for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
+ echo "$i) ${choices[$i-1]}"
+ done
+ done 2>&1
+fi
+
+# Launch rear recover automatically in unattended mode
+# i.e. with automated reboot after successful 'rear recover':
+if unattended_recovery ; then
+ choices=( "View Relax-and-Recover log file(s)"
+ "Go to Relax-and-Recover shell"
+ )
+ echo -e "\nLaunching 'rear recover' automatically in unattended mode\n"
+ if rear $rear_debug_options recover ; then
+ echo -e "\n'rear recover' finished successfully\n"
+ echo -e "\nRebooting in 30 seconds (Ctrl-C to interrupt)\n"
+ sleep 30
+ reboot
+ else
+ echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
+ PS3="Select what to do "
+ select choice in "${choices[@]}" ; do
+ case "$REPLY" in
+ (1)
+ # Do not assume the ReaR log file is named rear-$HOSTNAME.log
+ # the user can have specified any name as LOGFILE:
+ less /var/log/rear/*
+ ;;
+ (2)
+ echo "" > /etc/issue
+ echo "" > /etc/motd
+ break
+ ;;
+ esac
+ for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
+ echo "$i) ${choices[$i-1]}"
+ done
+ done 2>&1
+ fi
+fi
diff --git a/usr/share/rear/skel/default/etc/scripts/system-setup b/usr/share/rear/skel/default/etc/scripts/system-setup
index 1dc7f1e8..17487ac7 100755
--- a/usr/share/rear/skel/default/etc/scripts/system-setup
+++ b/usr/share/rear/skel/default/etc/scripts/system-setup
@@ -9,36 +9,7 @@
# (e.g. "ls foo*bar" becomes plain "ls" without "foo*bar: No such file or directory" error).
shopt -s nullglob
-# Use an artificial array to get the kernel command line parameters as array elements
-kernel_command_line=( $( cat /proc/cmdline ) )
-
-function rear_debug() {
- for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
- test "debug" = "$kernel_command_line_parameter" && return 0
- done
- return 1
-}
-
-function unattended_recovery() {
- for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
- test "unattended" = "$kernel_command_line_parameter" && return 0
- done
- return 1
-}
-
-function automatic_recovery() {
- # The unattended recovery mode implies automatic recovery (see the implementations below)
- # so that in unattended mode the automatic recovery code below must not be run
- # otherwise first the automatic recovery code and then the unattended recovery code
- # get run automatically one after the other where the unattended recovery fails
- # because for two subsequent 'rear recover' the second one fails:
- unattended_recovery && return 1
- for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
- test "auto_recover" = "$kernel_command_line_parameter" && return 0
- test "automatic" = "$kernel_command_line_parameter" && return 0
- done
- return 1
-}
+source /etc/scripts/system-setup-functions.sh
# The 'sleep 1' is used as workaround to avoid whatever inexplicable actual reason
# that at least on SLES12 some initial output lines of this script would get lost
@@ -135,84 +106,3 @@ echo -e "\nRelax-and-Recover rescue system is ready\n"
# Wait two seconds so that the user can read the 'Relax-and-Recover rescue system is ready' message
# on his screen before the screen gets cleared and replaced by the login screen:
sleep 2
-
-# In debug mode run the automated 'rear recover' also with debug options.
-# Because the kernel command line option 'debug' means 'set -x' for the system setup scripts
-# it also means '-D' (i.e. 'set -x') for the automated 'rear recover' run:
-if rear_debug ; then
- rear_debug_options='-D'
-else
- rear_debug_options=''
-fi
-
-# Launch rear recover automatically:
-if automatic_recovery ; then
- choices=( "View Relax-and-Recover log file(s)"
- "Go to Relax-and-Recover shell"
- )
- echo -e "\nLaunching 'rear recover' automatically\n"
- # The recover workflow is always verbose (see usr/sbin/rear):
- if rear $rear_debug_options recover ; then
- echo -e "\n'rear recover' finished successfully\n"
- choices+=( "Reboot" )
- else
- echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
- fi
- PS3="Select what to do "
- select choice in "${choices[@]}" ; do
- case "$REPLY" in
- (1)
- # Do not assume the ReaR log file is named rear-$HOSTNAME.log
- # the user can have specified any name as LOGFILE:
- less /var/log/rear/*
- ;;
- (2)
- echo "" > /etc/issue
- echo "" > /etc/motd
- break
- ;;
- (3)
- reboot
- ;;
- esac
- for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
- echo "$i) ${choices[$i-1]}"
- done
- done 2>&1
-fi
-
-# Launch rear recover automatically in unattended mode
-# i.e. with automated reboot after successful 'rear recover':
-if unattended_recovery ; then
- choices=( "View Relax-and-Recover log file(s)"
- "Go to Relax-and-Recover shell"
- )
- echo -e "\nLaunching 'rear recover' automatically in unattended mode\n"
- # The recover workflow is always verbose (see usr/sbin/rear):
- if rear $rear_debug_options recover ; then
- echo -e "\n'rear recover' finished successfully\n"
- echo -e "\nRebooting in 30 seconds (Ctrl-C to interrupt)\n"
- sleep 30
- reboot
- else
- echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
- PS3="Select what to do "
- select choice in "${choices[@]}" ; do
- case "$REPLY" in
- (1)
- # Do not assume the ReaR log file is named rear-$HOSTNAME.log
- # the user can have specified any name as LOGFILE:
- less /var/log/rear/*
- ;;
- (2)
- echo "" > /etc/issue
- echo "" > /etc/motd
- break
- ;;
- esac
- for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
- echo "$i) ${choices[$i-1]}"
- done
- done 2>&1
- fi
-fi
diff --git a/usr/share/rear/skel/default/etc/scripts/system-setup-functions.sh b/usr/share/rear/skel/default/etc/scripts/system-setup-functions.sh
new file mode 100644
index 00000000..c320cf88
--- /dev/null
+++ b/usr/share/rear/skel/default/etc/scripts/system-setup-functions.sh
@@ -0,0 +1,30 @@
+# Use an artificial array to get the kernel command line parameters as array elements
+kernel_command_line=( $( cat /proc/cmdline ) )
+
+function rear_debug() {
+ for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
+ test "debug" = "$kernel_command_line_parameter" && return 0
+ done
+ return 1
+}
+
+function unattended_recovery() {
+ for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
+ test "unattended" = "$kernel_command_line_parameter" && return 0
+ done
+ return 1
+}
+
+function automatic_recovery() {
+ # The unattended recovery mode implies automatic recovery (see the implementations below)
+ # so that in unattended mode the automatic recovery code below must not be run
+ # otherwise first the automatic recovery code and then the unattended recovery code
+ # get run automatically one after the other where the unattended recovery fails
+ # because for two subsequent 'rear recover' the second one fails:
+ unattended_recovery && return 1
+ for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
+ test "auto_recover" = "$kernel_command_line_parameter" && return 0
+ test "automatic" = "$kernel_command_line_parameter" && return 0
+ done
+ return 1
+}
diff --git a/usr/share/rear/skel/default/etc/systemd/system/default.target.wants/.gitignore b/usr/share/rear/skel/default/etc/systemd/system/default.target.wants/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/usr/share/rear/skel/default/etc/systemd/system/default.target.wants/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/automatic-rear.service b/usr/share/rear/skel/default/usr/lib/systemd/system/automatic-rear.service
new file mode 100644
index 00000000..ee3187a8
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/automatic-rear.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Run Relax-and-Recover recovery automatically if requested
+Wants=network-online.target
+After=network-online.target
+
+[Service]
+Type=oneshot
+ExecStart=/etc/scripts/run-automatic-rear
+StandardInput=tty
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service b/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service
index bf858ca8..abafd8b5 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service
@@ -6,6 +6,8 @@ Description=Getty on %I
Documentation=man:agetty(8)
After=systemd-user-sessions.service plymouth-quit-wait.service
After=sysinit.service
+# Automatic ReaR uses the system console
+After=automatic-rear.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target
index c5ea1cca..a88e219f 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target
@@ -4,7 +4,7 @@
[Unit]
Description=Multi-User
-Requires=sysinit.target
+Requires=sysinit.target basic.target
AllowIsolate=yes
[Install]
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target.wants/automatic-rear.service b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target.wants/automatic-rear.service
new file mode 120000
index 00000000..3e8a4161
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target.wants/automatic-rear.service
@@ -0,0 +1 @@
+../automatic-rear.service
\ No newline at end of file
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target
new file mode 100644
index 00000000..c3edfeb4
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Network is Online
+Documentation=man:systemd.special(7)
+Documentation=https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
+After=network.target
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target.wants/sysinit.service b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target.wants/sysinit.service
new file mode 120000
index 00000000..ed660a10
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target.wants/sysinit.service
@@ -0,0 +1 @@
+../sysinit.service
\ No newline at end of file
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service b/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service
index ac171e0f..18fa17b5 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service
@@ -1,6 +1,5 @@
[Unit]
Description=Relax-and-Recover run-syslog script
-DefaultDependencies=no
[Service]
Type=simple
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service
index ee22fafc..b34b2fe8 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service
@@ -1,9 +1,14 @@
[Unit]
Description=Initialize Rescue System
-After=systemd-udevd.service
+DefaultDependencies=no
+After=systemd-udevd.service rear-boot-helper.service
+Before=network-online.target
[Service]
Type=oneshot
ExecStart=/etc/scripts/system-setup
StandardInput=tty
RemainAfterExit=yes
+
+[Install]
+WantedBy=network-online.target
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target
index 4187ef67..2a16369b 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target
@@ -4,3 +4,5 @@
[Unit]
Description=System Initialization
+Wants=sysinit.service rear-boot-helper.service
+After=sysinit.service rear-boot-helper.service
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket b/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket
index 9a0064c0..3fb02344 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket
@@ -4,7 +4,6 @@
[Unit]
Description=Syslog Socket
-DefaultDependencies=no
Before=sockets.target syslog.target
[Socket]

1537
SOURCES/rear-fix-ipv6.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
diff --git a/usr/share/rear/build/default/990_verify_rootfs.sh b/usr/share/rear/build/default/990_verify_rootfs.sh
index 76a4f1f4b..1b76d8019 100644
--- a/usr/share/rear/build/default/990_verify_rootfs.sh
+++ b/usr/share/rear/build/default/990_verify_rootfs.sh
@@ -69,6 +69,11 @@ fi
Log "Testing each binary (except links) with ldd and look for 'not found' libraries within the recovery system"
local binary=""
local broken_binaries=""
+local not_found_output=""
+local not_found_library=""
+local junk=""
+local actually_found_library=""
+local actually_missing_libraries="no"
# Third-party backup tools may use LD_LIBRARY_PATH to find their libraries
# so that for testing such third-party backup tools we must also use
# their special LD_LIBRARY_PATH here:
@@ -151,7 +156,6 @@ test $old_LD_LIBRARY_PATH && export LD_LIBRARY_PATH=$old_LD_LIBRARY_PATH || unse
# Report binaries with 'not found' shared object dependencies:
local fatal_missing_library=""
if contains_visible_char "$broken_binaries" ; then
- LogPrintError "There are binaries or libraries in the ReaR recovery system that need additional libraries"
local ldd_output=""
for binary in $broken_binaries ; do
# Only for programs (i.e. files in a .../bin/... or .../sbin/... directory) treat a missing library as fatal
@@ -161,26 +165,43 @@ if contains_visible_char "$broken_binaries" ; then
if test "$NON_FATAL_BINARIES_WITH_MISSING_LIBRARY" ; then
# A program with missing library is treated as fatal when it does not match the pattern:
if grep -E -q "$NON_FATAL_BINARIES_WITH_MISSING_LIBRARY" <<<"$binary" ; then
- LogPrintError "$binary requires additional libraries (specified as non-fatal)"
+ LogPrint "$binary requires libraries where 'ldd' shows 'not found' (specified as non-fatal)"
else
- LogPrintError "$binary requires additional libraries (fatal error)"
+ LogPrint "$binary requires libraries where 'ldd' shows 'not found' (fatal error)"
fatal_missing_library="yes"
fi
else
- LogPrintError "$binary requires additional libraries (fatal error)"
+ LogPrint "$binary requires libraries where 'ldd' shows 'not found' (fatal by default)"
fatal_missing_library="yes"
fi
else
- LogPrintError "$binary requires additional libraries"
+ LogPrint "$binary requires libraries where 'ldd' shows 'not found'"
fi
# Run the same ldd call as above but now keep its whole output:
ldd_output="$( chroot $ROOTFS_DIR /bin/ldd $binary )"
# Have the whole ldd output only in the log:
Log "$ldd_output"
+ # For each 'not found' shared object (i.e. a shared object that was 'not found' by 'ldd')
+ # check whether or not the shared object may exist nevertheless in the ReaR recovery system
+ # and if yes, we may sufficiently safely assume things are OK in the ReaR recovery system
+ # so we do not report it as missing to the user (for debugging we have all in the log)
+ # cf. https://github.com/rear/rear/issues/3021#issuecomment-2165453757
+ not_found_output="$( grep 'not found' <<<"$ldd_output" )"
+ # not_found_output is a string of multiple lines (separated by \n) that look e.g. like
+ # libsystemd-shared-255.4-1.fc40.so => not found
+ # /path/to/library => not found
+ while read not_found_library junk ; do
+ # We prefer a simple 'grep -q' pipe over dealing with find -name versus -path options:
+ if actually_found_library="$( find $ROOTFS_DIR -xdev | grep "$not_found_library" )" ; then
+ LogPrint "$binary requires $not_found_library which was not found by 'ldd' but exists as $actually_found_library"
+ else
+ actually_missing_libraries="yes"
# Show only the missing libraries to the user to not flood his screen with tons of other ldd output lines:
- PrintError "$( grep 'not found' <<<"$ldd_output" )"
+ LogPrintError "$binary requires $not_found_library which could not be found in the ReaR recovery system"
+ fi
+ done <<<"$not_found_output"
done
- LogPrintError "ReaR recovery system in '$ROOTFS_DIR' needs additional libraries, check $RUNTIME_LOGFILE for details"
+ is_true $actually_missing_libraries && LogPrintError "ReaR recovery system in '$ROOTFS_DIR' needs additional libraries, check $RUNTIME_LOGFILE for details"
is_true "$fatal_missing_library" && keep_build_dir
fi

View File

@ -0,0 +1,117 @@
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
index 17a764cba..a944114b3 100644
--- a/usr/share/rear/conf/default.conf
+++ b/usr/share/rear/conf/default.conf
@@ -1866,7 +1866,7 @@ OBDR_BLOCKSIZE=2048
# BACKUP=NBU stuff (Symantec/Veritas NetBackup)
##
#
-COPY_AS_IS_NBU=( /usr/openv/bin/vnetd /usr/openv/bin/vopied /usr/openv/lib /usr/openv/netbackup /usr/openv/var/auth/[mn]*.txt /usr/openv/var/vxss /usr/openv/var/webtruststore /usr/openv/resources/nbpxyhelper /opt/VRTSpbx /etc/vx/VxICS /etc/vx/vrtslog.conf /var/log/VRTSpbx )
+COPY_AS_IS_NBU=( /usr/openv/bin/vnetd /usr/openv/bin/vopied /usr/openv/lib /usr/openv/netbackup /usr/openv/var /usr/openv/resources/nbpxyhelper /opt/VRTSpbx /etc/vx/VxICS /etc/vx/vrtslog.conf /var/log/VRTSpbx )
COPY_AS_IS_EXCLUDE_NBU=( "/usr/openv/netbackup/logs/*" "/usr/openv/netbackup/bin/bpjava*" /usr/openv/netbackup/bin/xbp /usr/openv/netbackup/bin/private /usr/openv/lib/java "/usr/openv/lib/*-plugins" /usr/openv/lib/shared/vddk /usr/openv/netbackup/baremetal "/var/log/VRTSpbx/*" )
# See https://github.com/rear/rear/issues/2105 why /usr/openv/netbackup/sec/at/lib/ is needed:
NBU_LD_LIBRARY_PATH="/usr/openv/lib:/usr/openv/netbackup/sec/at/lib/:/usr/openv/lib/boost"
diff --git a/usr/share/rear/finalize/NBU/default/990_copy_bplogrestorelog.sh b/usr/share/rear/finalize/NBU/default/990_copy_bplogrestorelog.sh
index 60d9a222c..e326db612 100644
--- a/usr/share/rear/finalize/NBU/default/990_copy_bplogrestorelog.sh
+++ b/usr/share/rear/finalize/NBU/default/990_copy_bplogrestorelog.sh
@@ -1,5 +1,51 @@
# 990_copy_bprestorelog.sh
-# copy the logfile to the recovered system, at least the part that has been written till now.
+# copy the logfiles to the recovered system, at least the part that has been written till now.
-mkdir -p $TARGET_FS_ROOT/$ROOT_HOME_DIR
-cp -f $TMP_DIR/bplog.restore* $TARGET_FS_ROOT/$ROOT_HOME_DIR/
+# $VAR_DIR/restore will be copied to $recovery_system_recover_log_dir in wrapup/default/990_copy_logfile.sh
+mkdir -p "$VAR_DIR/restore/netbackup"
+cp -pr /usr/openv/netbackup/logs/* "$VAR_DIR/restore/netbackup"
+
+# take care of $VAR_DIR/restore/bplog.restore* files (that used to be in /root before)
+function symlink_bprestore_logs ()
+{
+ # adapted from wrapup/default/990_copy_logfile.sh
+ local final_logfile_name_full
+ local final_logfile_name
+ local log_file_symlink_target
+ local log_file_symlink
+ local recover_log_dir=$LOG_DIR/recover
+ local recovery_system_recover_log_dir=$TARGET_FS_ROOT/$recover_log_dir
+ # Create the directories with mode 0700 (rwx------) so that only root can access files and subdirectories therein
+ # because in particular logfiles could contain security relevant information.
+
+ # To be backward compatible with where to the logfile was copied before
+ # have it as a symbolic link that points to where the logfile actually is:
+ # ( "roots" in recovery_system_roots_home_dir means root's but ' in a variable name is not so good ;-)
+ local recovery_system_roots_home_dir=$TARGET_FS_ROOT/$ROOT_HOME_DIR
+ test -d $recovery_system_roots_home_dir || mkdir $verbose -m 0700 $recovery_system_roots_home_dir
+
+ # Remove existing and now outdated symlinks that would falsely point to the same target
+ # The symlink name bplog.restore-$( date -Iseconds ).log is for example bplog.restore-2019-12-17T09:40:36+01:00.log or rear-2006-08-14T02:34:56-06:00.log
+ # so a matching globbing pattern is bplog.restore-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]*.log ('*' for the UTC offset):
+ for log_file_symlink in $recovery_system_roots_home_dir/bplog.restore*-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]*.log ; do
+ # Skip if a file that matches the globbing pattern is not a symlink (it could be even a directory full of user's sacrocanct files):
+ test -L $log_file_symlink || continue
+ # Remove also outdated dangling symlinks where their target does not exist by using 'readlink -m':
+ test "$log_file_symlink_target" = "$( readlink -m $log_file_symlink )" || continue
+ rm $verbose $log_file_symlink
+ done
+
+ # At the moment this function runs, $VAR_DIR/restore will have been already copied
+ # to $recovery_system_recover_log_dir in wrapup/default/990_copy_logfile.sh
+ # (exit tasks run in reverse order, so this task will run after the tasks defined in
+ # wrapup/default/990_copy_logfile.sh )
+ for final_logfile_name_full in $recovery_system_recover_log_dir/restore/bplog.restore* ; do
+ final_logfile_name="$( basename "$final_logfile_name_full" )"
+ log_file_symlink_target="$recover_log_dir/restore/$final_logfile_name"
+ # Create symlink with current timestamp that points to where the logfile actually is:
+ log_file_symlink=$recovery_system_roots_home_dir/$( basename "$final_logfile_name" .log )-$( date -Iseconds ).log
+ ln $verbose -s $log_file_symlink_target $log_file_symlink || true
+ done
+}
+
+AddExitTask "symlink_bprestore_logs"
diff --git a/usr/share/rear/restore/NBU/default/400_restore_with_nbu.sh b/usr/share/rear/restore/NBU/default/400_restore_with_nbu.sh
index 71f7359a1..4280cb021 100644
--- a/usr/share/rear/restore/NBU/default/400_restore_with_nbu.sh
+++ b/usr/share/rear/restore/NBU/default/400_restore_with_nbu.sh
@@ -2,6 +2,23 @@
# 400_restore_with_nbu.sh
# restore files with NBU
+# Unique log file name: adapted from restore/NETFS/default/400_restore_backup.sh
+# and restore/TSM/default/400_restore_with_tsm.sh
+local backup_restore_log_dir="$VAR_DIR/restore"
+mkdir -p $backup_restore_log_dir
+local backup_restore_log_file=""
+local backup_restore_log_prefix="bplog.restore"
+local backup_restore_log_suffix="log"
+# E.g. when "rear -C 'general.conf /path/to/special.conf' recover" was called CONFIG_APPEND_FILES is "general.conf /path/to/special.conf"
+# so that in particular '/' characters must be replaced in the backup restore log file (by a colon) and then
+# the backup restore log file name will be like .../restore/bplog.restore.generalconf_:path:to:specialconf.1234.log
+# It does not work with $( tr -d -c '[:alnum:]/[:space:]' <<<"$CONFIG_APPEND_FILES" | tr -s '/[:space:]' ':_' )
+# because the <<<"$CONFIG_APPEND_FILES" results a trailing newline that becomes a trailing '_' character so that
+# echo -n $CONFIG_APPEND_FILES (without double quotes) is used to avoid leading and trailing spaces and newlines:
+test "$CONFIG_APPEND_FILES" && backup_restore_log_prefix=$backup_restore_log_prefix.$( echo -n $CONFIG_APPEND_FILES | tr -d -c '[:alnum:]/[:space:]' | tr -s '/[:space:]' ':_' )
+
+backup_restore_log_file=$backup_restore_log_dir/$backup_restore_log_prefix.$MASTER_PID.$backup_restore_log_suffix
+
LogPrint "NetBackup: restoring / into $TARGET_FS_ROOT"
echo "change / to $TARGET_FS_ROOT" > $TMP_DIR/nbu_change_file
@@ -10,13 +27,13 @@ echo "change / to $TARGET_FS_ROOT" > $TMP_DIR/nbu_change_file
# $TMP_DIR/restore_fs_list was made by 300_create_nbu_restore_fs_list.sh
if [ ${#NBU_ENDTIME[@]} -gt 0 ] ; then
edate="${NBU_ENDTIME[@]}"
- bprestore_args="-B -H -L $TMP_DIR/bplog.restore -8 -R $TMP_DIR/nbu_change_file -t 0 -w 0 -e ${edate} -C ${NBU_CLIENT_SOURCE} -D ${NBU_CLIENT_NAME} -f $TMP_DIR/restore_fs_list"
+ bprestore_args="-B -H -L $backup_restore_log_file -8 -R $TMP_DIR/nbu_change_file -t 0 -w 0 -e ${edate} -C ${NBU_CLIENT_SOURCE} -D ${NBU_CLIENT_NAME} -f $TMP_DIR/restore_fs_list"
else
- bprestore_args="-B -H -L $TMP_DIR/bplog.restore -8 -R $TMP_DIR/nbu_change_file -t 0 -w 0 -C ${NBU_CLIENT_SOURCE} -D ${NBU_CLIENT_NAME} -f $TMP_DIR/restore_fs_list"
+ bprestore_args="-B -H -L $backup_restore_log_file -8 -R $TMP_DIR/nbu_change_file -t 0 -w 0 -C ${NBU_CLIENT_SOURCE} -D ${NBU_CLIENT_NAME} -f $TMP_DIR/restore_fs_list"
fi
LogPrint "RUN: /usr/openv/netbackup/bin/bprestore $bprestore_args"
-LogPrint "Restore progress: see $TMP_DIR/bplog.restore"
+LogPrint "Restore progress: see $backup_restore_log_file"
LANG=C /usr/openv/netbackup/bin/bprestore $bprestore_args
rc=$?
if (( $rc > 1 )) ; then

View File

@ -0,0 +1,84 @@
diff --git a/usr/share/rear/format/USB/default/300_format_usb_disk.sh b/usr/share/rear/format/USB/default/300_format_usb_disk.sh
index 0e0a2e080..fa6496b23 100644
--- a/usr/share/rear/format/USB/default/300_format_usb_disk.sh
+++ b/usr/share/rear/format/USB/default/300_format_usb_disk.sh
@@ -94,7 +94,13 @@ sleep 5
if is_true "$EFI" ; then
LogPrint "Creating vfat filesystem on EFI system partition on '${RAW_USB_DEVICE}1'"
- if ! mkfs.vfat $v -F 16 -n REAR-EFI ${RAW_USB_DEVICE}1 >&2 ; then
+ # Make a FAT filesystem on the EFI system partition
+ # cf. https://github.com/rear/rear/issues/2575
+ # and output/ISO/Linux-i386/700_create_efibootimg.sh
+ # and output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh
+ # Let mkfs.vfat automatically select the FAT type based on the size.
+ # I.e. do not use a '-F 16' or '-F 32' option and hope for the best:
+ if ! mkfs.vfat $v -n REAR-EFI ${RAW_USB_DEVICE}1 >&2 ; then
Error "Failed to create vfat filesystem on '${RAW_USB_DEVICE}1'"
fi
# create link for EFI partition in /dev/disk/by-label
diff --git a/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh b/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh
index 0eb5350f8..39bbebad8 100644
--- a/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh
+++ b/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh
@@ -13,13 +13,33 @@ StopIfError "Failed to determine disk usage of EFI virtual image content directo
# prepare EFI virtual image aligned to 32MiB blocks:
dd if=/dev/zero of=$TMP_DIR/efiboot.img count=$efi_img_sz bs=32M
-mkfs.vfat $v -F 16 $TMP_DIR/efiboot.img >&2
-mkdir -p $v $TMP_DIR/efi_virt >&2
-mount $v -o loop -t vfat -o fat=16 $TMP_DIR/efiboot.img $TMP_DIR/efi_virt >&2
-# copy files from staging directory
+# Make a FAT filesystem on the efiboot.img file and loop mount it
+# cf. https://github.com/rear/rear/issues/2575
+# See output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh
+# Having a small EFI System Partition (ESP) might introduce problems:
+# - The UEFI spec seems to require a FAT32 EFI System Partition (ESP).
+# - syslinux/Legacy BIOS fails to install on small FAT32 partitions with "syslinux: zero FAT sectors (FAT12/16)".
+# - Some firmwares fail to boot from small FAT32 partitions.
+# - Some firmwares fail to boot from FAT16 partitions.
+# See:
+# - http://www.rodsbooks.com/efi-bootloaders/principles.html
+# - http://lists.openembedded.org/pipermail/openembedded-core/2012-January/055999.html
+# Let mkfs.vfat automatically select the FAT type based on the size.
+# See what "man mkfs.vfat" reads for the '-F' option:
+# "If nothing is specified, mkfs.fat will automatically select
+# between 12, 16 and 32 bit, whatever fits better for the filesystem size"
+# I.e. do not use a '-F 16' or '-F 32' option and hope for the best:
+mkfs.vfat $v $TMP_DIR/efiboot.img
+mkdir -p $v $TMP_DIR/efi_virt
+# Do not specify '-o fat=16' or '-o fat=32' when loop mounting the efiboot.img FAT file
+# but rely on the automatic FAT type detection (see what "man 8 mount" reads for 'fat=...'):
+mount $v -o loop -t vfat $TMP_DIR/efiboot.img $TMP_DIR/efi_virt || Error "Failed to loop mount efiboot.img"
+
+# Copy files from staging directory into efiboot.img
cp $v -r $TMP_DIR/mnt/. $TMP_DIR/efi_virt
-umount $v $TMP_DIR/efiboot.img >&2
-mv $v -f $TMP_DIR/efiboot.img $TMP_DIR/isofs/boot/efiboot.img >&2
-StopIfError "Could not move efiboot.img file"
+umount $v $TMP_DIR/efiboot.img
+
+# Move efiboot.img into ISO directory:
+mv $v -f $TMP_DIR/efiboot.img $TMP_DIR/isofs/boot/efiboot.img || Error "Failed to move efiboot.img to isofs/boot/efiboot.img"
diff --git a/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh b/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh
index b5f603ec5..716d7d383 100644
--- a/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh
+++ b/usr/share/rear/output/ISO/Linux-ia64/200_mount_bootimg.sh
@@ -1,6 +1,11 @@
# 200_mount_bootimg.sh
dd if=/dev/zero of=$TMP_DIR/boot.img count=64000 bs=1024
-# make sure we select FAT16 instead of FAT12 as size >30MB
-mkfs.vfat $v -F 16 $TMP_DIR/boot.img >&2
-mkdir -p $v $TMP_DIR/mnt >&2
-mount $v -o loop -t vfat -o fat=16 $TMP_DIR/boot.img $TMP_DIR/mnt >&2
+# Make a FAT filesystem on the boot.img file and loop mount it
+# cf. https://github.com/rear/rear/issues/2575
+# and output/ISO/Linux-i386/700_create_efibootimg.sh
+# and output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh
+# Let mkfs.vfat automatically select the FAT type based on the size.
+# I.e. do not use a '-F 16' or '-F 32' option and hope for the best:
+mkfs.vfat $v $TMP_DIR/boot.img
+mkdir -p $v $TMP_DIR/mnt
+mount $v -o loop -t vfat $TMP_DIR/boot.img $TMP_DIR/mnt || Error "Failed to loop mount boot.img"

View File

@ -0,0 +1,46 @@
commit ad720ad788be1d653da31be36fca5e886e314ddb
Author: Pavel Cahyna <pcahyna@redhat.com>
Date: Thu Aug 24 11:41:25 2023 +0200
Remove the lvmdevices file at the end of recovery
The file /etc/lvm/devices/system.devices restricts LVM to disks with
given (hardware) IDs (serial numbers, WWNs). See lvmdevices(8).
Unfortunately, when restoring to different disks than in the original
system, it will mean that LVM is broken in the recovered system (it
won't find any disks). Therefore it is safer to remove the file to
force the old behavior where LVM scans all disks. This used to be the
LVM default (use_devicesfile=0).
diff --git a/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh b/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh
new file mode 100644
index 00000000..a51e6bca
--- /dev/null
+++ b/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh
@@ -0,0 +1,25 @@
+# Adapted from 260_rename_diskbyid.sh
+
+# Remove /etc/lvm/devices/system.devices
+# The file restricts LVM to disks with given (hardware) IDs (serial
+# numbers, WWNs). See lvmdevices(8).
+# Unfortunately, when restoring to different disks than in the original
+# system, it will mean that LVM is broken in the recovered system (it
+# won't find any disks). Therefore it is safer to remove the file to
+# force the old behavior where LVM scans all disks. This used to be the
+# LVM default (use_devicesfile=0).
+
+# There may be other files under /etc/lvm/devices, but they are not used
+# by default
+
+local file=/etc/lvm/devices/system.devices
+local realfile
+
+realfile="$TARGET_FS_ROOT/$file"
+# OK if file not found
+test -f "$realfile" || return 0
+mv $v "$realfile" "${realfile}.rearbak"
+LogPrint "Renamed LVM devices file $realfile to ${realfile}.rearbak
+to prevent LVM problems in the recovered system, verify that the file
+is correct after booting the recovered system and move it back, or
+regenerate it using vgimportdevices."

View File

@ -0,0 +1,21 @@
diff --git a/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh b/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh
index 0e402b017..9e1810c9a 100644
--- a/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh
+++ b/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh
@@ -117,10 +117,13 @@ local copy_as_is_file=""
# cf. https://github.com/rear/rear/pull/2378
# It is crucial to append to /dev/$DISPENSABLE_OUTPUT_DEV (cf. 'Print' in lib/_input-output-functions.sh):
while read -r copy_as_is_file ; do
- # Skip non-regular files like directories, device files, and 'tar' error messages (e.g. in case of non-existent files, see above):
+ # Skip non-regular files like directories, device files, and 'tar' error messages (e.g. in case of non-existent files, see above)
+ # but do not skip symbolic links. Their targets will be copied later by build/default/490_fix_broken_links.sh.
+ # We thus need library dependencies for symlinked executables just like for normal executables
+ # and build/default/490_fix_broken_links.sh does not perform library dependency scan.
+ # See GitHub PR https://github.com/rear/rear/pull/3073
+ # and issue https://github.com/rear/rear/issues/3064 for details.
test -f "$copy_as_is_file" || continue
- # Skip symbolic links (only care about symbolic link targets):
- test -L "$copy_as_is_file" && continue
# Remember actual regular files that are executable:
test -x "$copy_as_is_file" && copy_as_is_executables+=( "$copy_as_is_file" )
done < <( sort -u $copy_as_is_filelist_file ) 2>>/dev/$DISPENSABLE_OUTPUT_DEV

View File

@ -0,0 +1,63 @@
diff --git a/usr/sbin/rear b/usr/sbin/rear
index d2cb6c070..ea66f0a98 100755
--- a/usr/sbin/rear
+++ b/usr/sbin/rear
@@ -376,6 +376,10 @@ fi
# and fd6 to get input from the user regardless where to STDIN is redirected:
source $SHARE_DIR/lib/_input-output-functions.sh
+# Used to determine whether TMPDIR has been changed in user config.
+# Save the current value to detect changes.
+saved_tmpdir="${TMPDIR-}"
+
# Keep old log file:
test -r "$RUNTIME_LOGFILE" && mv -f "$RUNTIME_LOGFILE" "$RUNTIME_LOGFILE".old 2>/dev/null
@@ -446,6 +450,14 @@ for config in site local rescue ; do
test "$( tr -d -c '\r' < $CONFIG_DIR/$config.conf )" && Error "Carriage return character in $CONFIG_DIR/$config.conf (perhaps DOS or Mac format)"
Source "$CONFIG_DIR/$config.conf" || true
fi
+ if [ "$config" == local ] ; then
+ # changing TMPDIR in rescue.conf is expected for now, see
+ # rescue/GNU/Linux/600_unset_TMPDIR_in_rescue_conf.sh,
+ # so perform the check after reading local.conf but before rescue.conf
+ if [ "$saved_tmpdir" != "${TMPDIR-}" ] ; then
+ LogPrintError "Warning: Setting TMPDIR in a configuration file is deprecated. To specify a working area directory prefix, export TMPDIR before executing '$PROGRAM'"
+ fi
+ fi
done
# Finally source additional configuration files if specified on the command line:
if test "$CONFIG_APPEND_FILES" ; then
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
index d5fe6dcc4..4e67e38c9 100644
--- a/usr/share/rear/conf/default.conf
+++ b/usr/share/rear/conf/default.conf
@@ -50,12 +50,9 @@
# which usually results /tmp/rear.XXXXXXXXXXXXXXX or $TMPDIR/rear.XXXXXXXXXXXXXXX
# the latter when the canonical Linux/Unix environment variable TMPDIR
# is set in the environment where /usr/sbin/rear is called.
-# To have a specific working area directory prefix for Relax-and-Recover
-# specify in /etc/rear/local.conf something like
-#
+# To have a specific working area directory prefix for Relax-and-Recover call
# export TMPDIR="/prefix/for/rear/working/directory"
-#
-# where /prefix/for/rear/working/directory must already exist.
+# before calling 'rear' (/prefix/for/rear/working/directory must already exist).
# This is useful for example when there is not sufficient free space
# in /var/tmp or $TMPDIR for the ISO image or even the backup archive.
# TMPDIR cannot be set to a default value here unconditionally but only
diff --git a/usr/share/rear/rescue/GNU/Linux/600_unset_TMPDIR_in_rescue_conf.sh b/usr/share/rear/rescue/GNU/Linux/600_unset_TMPDIR_in_rescue_conf.sh
new file mode 100644
index 000000000..84d0cabb2
--- /dev/null
+++ b/usr/share/rear/rescue/GNU/Linux/600_unset_TMPDIR_in_rescue_conf.sh
@@ -0,0 +1,8 @@
+cat - <<EOF >> "$ROOTFS_DIR/etc/rear/rescue.conf"
+# TMPDIR variable may be defined in local.conf file as prefix dir for mktemp command
+# e.g. by defining TMPDIR=/var we would get our BUILD_DIR=/var/tmp/rear.XXXXXXXXXXXX
+# However, in rescue we want our BUILD_DIR=/tmp/rear.XXXXXXX as we are not sure that
+# the user defined TMPDIR would exist in our rescue image
+# by 'unset TMPDIR' we achieve above goal (as rescue.conf is read after local.conf)!
+unset TMPDIR
+EOF

37
SOURCES/rear-tmpdir.patch Normal file
View File

@ -0,0 +1,37 @@
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
index 9ada92c3..3bdb5497 100644
--- a/usr/share/rear/conf/default.conf
+++ b/usr/share/rear/conf/default.conf
@@ -57,10 +57,16 @@
#
# where /prefix/for/rear/working/directory must already exist.
# This is useful for example when there is not sufficient free space
-# in /tmp or $TMPDIR for the ISO image or even the backup archive.
-# TMPDIR cannot be set to a default value here, otherwise /usr/sbin/rear
+# in /var/tmp or $TMPDIR for the ISO image or even the backup archive.
+# TMPDIR cannot be set to a default value here unconditionally but only
+# if it is not set before calling the program, otherwise /usr/sbin/rear
# would not work in compliance with the Linux/Unix standards regarding TMPDIR
# see https://github.com/rear/rear/issues/968
+# The default is /var/tmp instead of the more usual /tmp (the system default),
+# because /tmp is not intended for such large amounts of data that ReaR usually
+# produces when creating the image (see file-hierarchy(7)). In particular,
+# /tmp can be a tmpfs, and thus restricted by the available RAM/swap.
+export TMPDIR="${TMPDIR-/var/tmp}"
##
# ROOT_HOME_DIR
diff --git a/usr/share/rear/rescue/GNU/Linux/600_unset_TMPDIR_in_rescue_conf.sh b/usr/share/rear/rescue/GNU/Linux/600_unset_TMPDIR_in_rescue_conf.sh
deleted file mode 100644
index 84d0cabb..00000000
--- a/usr/share/rear/rescue/GNU/Linux/600_unset_TMPDIR_in_rescue_conf.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-cat - <<EOF >> "$ROOTFS_DIR/etc/rear/rescue.conf"
-# TMPDIR variable may be defined in local.conf file as prefix dir for mktemp command
-# e.g. by defining TMPDIR=/var we would get our BUILD_DIR=/var/tmp/rear.XXXXXXXXXXXX
-# However, in rescue we want our BUILD_DIR=/tmp/rear.XXXXXXX as we are not sure that
-# the user defined TMPDIR would exist in our rescue image
-# by 'unset TMPDIR' we achieve above goal (as rescue.conf is read after local.conf)!
-unset TMPDIR
-EOF

4
SOURCES/rear.cron Normal file
View File

@ -0,0 +1,4 @@
# cronjob for ReaR
# periodically check if disk layout has changed and update
# the rescue image
30 1 * * * root test -f /var/lib/rear/layout/disklayout.conf && /usr/sbin/rear checklayout || /usr/sbin/rear mkrescue

6
SOURCES/rear.service Normal file
View File

@ -0,0 +1,6 @@
[Unit]
Description=Update ReaR rescue image
[Service]
Type=oneshot
ExecStart=/usr/sbin/rear checklayout || /usr/sbin/rear mkrescue

10
SOURCES/rear.timer Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Update ReaR rescue image
[Timer]
OnCalendar=daily
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target

864
SOURCES/rsync-output.patch Normal file
View File

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

View File

@ -1,21 +1,27 @@
%define debug_package %{nil}
# this is purely a shell script, so no debug packages
%global debug_package %{nil}
Summary: Relax-and-Recover is a Linux disaster recovery and system migration tool
Name: rear
Version: 2.6
Release: 12%{?dist}
License: GPLv3
Group: Applications/File
Release: 25%{?dist}
Summary: Relax-and-Recover is a Linux disaster recovery and system migration tool
URL: http://relax-and-recover.org/
License: GPLv3
Source0: https://github.com/rear/rear/archive/%{version}.tar.gz#/rear-%{version}.tar.gz
# Add cronjob and systemd timer as documentation
Source1: rear.cron
Source2: rear.service
Source3: rear.timer
# Skip buildin modules, RHBZ#1831311
Patch0: 0001-skip-kernel-buildin-modules.patch
Patch4: rear-bz1492177-warning.patch
Patch29: rear-bz1832394.patch
Patch30: rear-sfdc02772301.patch
Patch31: rear-bz1945869.patch
Patch32: rear-bz1958247.patch
Patch33: rear-bz1930662.patch
Patch34: rear-asciidoc.patch
Patch34: rear-tmpdir.patch
Patch35: rear-bz1983013.patch
Patch36: rear-bz1993296.patch
Patch37: rear-bz1747468.patch
@ -26,19 +32,25 @@ Patch41: rear-bz2035939.patch
Patch42: rear-bz2083272.patch
Patch43: rear-bz2111049.patch
Patch44: rear-bz2104005.patch
Patch45: rear-bz2097437.patch
Patch46: rear-bz2096916.patch
Patch47: rear-bz2096900.patch
Patch48: rear-bz2111059.patch
Patch49: pxe-rsync-output.patch
Patch49: rsync-output.patch
Patch50: rear-bz2119501.patch
Patch51: rear-bz2120736.patch
Patch52: rear-bz2091163.patch
Patch53: rear-bz2130945.patch
Patch54: rear-bz2131946.patch
Patch52: rear-bz2117937.patch
Patch53: rear-bz2091163.patch
Patch54: rear-bz2130945.patch
Patch55: rear-bz2131946.patch
Patch56: s390-no-clobber-disks.patch
Patch57: rear-bz2188593-nbu-systemd.patch
Patch58: rear-device-shrinking-bz2223895.patch
Patch59: rear-usb-uefi-part-size-bz2228402.patch
Patch60: rear-luks-key-bz2228779.patch
Patch61: rear-uefi-usb-secureboot-bz2196445.patch
Patch62: rear-vg-command-not-found-bz2121476.patch
Patch63: rear-remove-lvmdevices-bz2145014.patch
Patch64: rear-save-lvm-poolmetadatasize-RHEL-6984.patch
Patch65: rear-skip-useless-xfs-mount-options-RHEL-10478.patch
@ -50,52 +62,52 @@ Patch111: rear-CVE-2024-23301.patch
# https://github.com/rear/rear/pull/3145
Patch113: rear-restore-hybrid-bootloader-RHEL-16864.patch
# Resolve libs for executable links in COPY_AS_IS
# https://github.com/rear/rear/commit/9f859c13f5ba285cd1d5983c9b595975c21888d3
Patch114: rear-resolve-libraries-for-symlinks-in-COPY_AS_IS-RHEL-15108.patch
# Skip invalid disk drives (zero sized, no media) when saving layout
# https://github.com/rear/rear/commit/808b15a677191aac62faadd1bc71885484091316
Patch115: rear-skip-invalid-drives-RHEL-22863.patch
### Dependencies on all distributions
BuildRequires: asciidoc
Requires: binutils
Requires: ethtool
Requires: gzip
Requires: iputils
Requires: parted
Requires: tar
Requires: openssl
Requires: gawk
Requires: attr
Requires: bc
Requires: file
Requires: dhcp-client
# Fix useless warning that libsystemd-core requires additional libraries
# and ReaR recovery system needs additional libraries
# https://github.com/rear/rear/pull/3250
Patch116: rear-fix-libsystemd-ldd-warning.patch
### If you require NFS, you may need the below packages
#Requires: nfsclient portmap rpcbind
# Fix IPv6 addresses in nfs:// and sshfs:// BACKUP/OUTPUT_URL
# https://github.com/rear/rear/pull/3242
Patch117: rear-fix-ipv6.patch
### We drop LSB requirements because it pulls in too many dependencies
### The OS is hardcoded in /etc/rear/os.conf instead
#Requires: redhat-lsb
# Remove obsolete FAT16 options to avoid kernel warning
# https://github.com/rear/rear/pull/2576
Patch118: rear-no-fat-16.patch
### Required for Bacula/MySQL support
#Requires: bacula-mysql
######################
# downstream patches #
######################
### Required for OBDR
#Requires: lsscsi sg3_utils
# additional fixes for NBU support
Patch206: rear-nbu-RHEL-17390-RHEL-17393.patch
### Optional requirement
#Requires: cfg2html
# support "export TMPDIR" again, temporarily, with a warning.
Patch207: rear-support-export-TMPDIR.patch
%ifarch x86_64 i686
# rear contains only bash scripts plus documentation so that on first glance it could be "BuildArch: noarch"
# but actually it is not "noarch" because it only works on those architectures that are explicitly supported.
# Of course the rear bash scripts can be installed on any architecture just as any binaries can be installed on any architecture.
# But the meaning of architecture dependent packages should be on what architectures they will work.
# Therefore only those architectures that are actually supported are explicitly listed.
# This avoids that rear can be "just installed" on architectures that are actually not supported (e.g. ARM):
ExclusiveArch: %ix86 x86_64 ppc ppc64 ppc64le ia64 s390x
# Furthermore for some architectures it requires architecture dependent packages (like syslinux for x86 and x86_64)
# so that rear must be architecture dependent because ifarch conditions never match in case of "BuildArch: noarch"
# see the GitHub issue https://github.com/rear/rear/issues/629
%ifarch %ix86 x86_64
Requires: syslinux
%endif
%ifarch x86_64 i686 aarch64
# We need mkfs.vfat for recreating EFI System Partition
Recommends: dosfstools
%endif
%ifarch ppc ppc64
Requires: yaboot
%endif
%ifarch ppc ppc64 ppc64le
# Called by grub2-install (except on PowerNV)
Requires: /usr/sbin/ofpathname
@ -107,26 +119,37 @@ Requires: /usr/sbin/bootlist
Requires: s390utils-base
Requires: s390utils-core
%endif
# In the end this should tell the user that rear is known to work only on ix86 x86_64 ppc ppc64 ppc64le ia64
# and on ix86 x86_64 syslinux is explicitly required to make the bootable ISO image
# (in addition to the default installed bootloader grub2) while on ppc ppc64 the
# default installed bootloader yaboot is also useed to make the bootable ISO image.
Requires: crontabs
# Required for HTML user guide
BuildRequires: make
BuildRequires: asciidoctor
### Mandatory dependencies:
Requires: binutils
Requires: ethtool
Requires: gzip
Requires: iputils
Requires: parted
Requires: tar
Requires: openssl
Requires: gawk
Requires: attr
Requires: bc
Requires: iproute
# No ISO image support on s390x (may change when we add support for LPARs)
%ifnarch s390x
Requires: xorriso
%endif
# mingetty is not available anymore with RHEL 7 (use agetty instead via systemd)
# Note that CentOS also has rhel defined so there is no need to use centos
%if 0%{?rhel} && 0%{?rhel} > 6
Requires: util-linux
%else
Requires: mingetty
Requires: file
Requires: dhcp-client
%if 0%{?rhel}
Requires: util-linux
%endif
### The rear-snapshot package is no more
#Obsoletes: rear-snapshot
%description
Relax-and-Recover is the leading Open Source disaster recovery and system
migration solution. It comprises of a modular
@ -138,7 +161,7 @@ a migration tool as well.
Currently Relax-and-Recover supports various boot media (incl. ISO, PXE,
OBDR tape, USB or eSATA storage), a variety of network protocols (incl.
sftp, ftp, http, nfs, cifs) as well as a multitude of backup strategies
(incl. IBM TSM, HP DataProtector, Symantec NetBackup, EMC NetWorker,
(incl. IBM TSM, MircroFocus Data Protector, Symantec NetBackup, EMC NetWorker,
Bacula, Bareos, BORG, Duplicity, rsync).
Relax-and-Recover was designed to be easy to set up, requires no maintenance
@ -147,93 +170,92 @@ removes any excuse for not having a disaster recovery solution implemented.
Professional services and support are available.
%pre
if [ $1 -gt 1 ] ; then
# during upgrade remove obsolete directories
%{__rm} -rf %{_datadir}/rear/output/NETFS
fi
#-- PREP, BUILD & INSTALL -----------------------------------------------------#
%prep
%setup
%patch4 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch56 -p1
%patch58 -p1
%patch59 -p1
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch64 -p1
%patch65 -p1
%patch111 -p1
%patch113 -p1
%patch115 -p1
echo "30 1 * * * root test -f /var/lib/rear/layout/disklayout.conf && /usr/sbin/rear checklayout || /usr/sbin/rear mkrescue" >rear.cron
%autosetup -p1
### Add a specific os.conf so we do not depend on LSB dependencies
%{?fedora:echo -e "OS_VENDOR=Fedora\nOS_VERSION=%{?fedora}" >etc/rear/os.conf}
%{?rhel:echo -e "OS_VENDOR=RedHatEnterpriseServer\nOS_VERSION=%{?rhel}" >etc/rear/os.conf}
# Change /lib to /usr/lib for COPY_AS_IS
sed -E -e "s:([\"' ])/lib:\1/usr/lib:g" \
-i usr/share/rear/prep/GNU/Linux/*include*.sh
# Same for Linux.conf
sed -e 's:/lib/:/usr/lib/:g' \
-e 's:/lib\*/:/usr/lib\*/:g' \
-e 's:/usr/usr/lib:/usr/lib:g' \
-i 'usr/share/rear/conf/GNU/Linux.conf'
%build
# build HTML user guide
# asciidoc writes a timestamp to files it produces, based on the last
# modified date of the source file, but is sensible to the timezone.
# modified date of the source file, but is sensitive to the timezone.
# This makes the results differ according to the timezone of the build machine
# and spurious changes will be seen.
# Set the timezone to UTC as a workaround.
# https://wiki.debian.org/ReproducibleBuilds/TimestampsInDocumentationGeneratedByAsciidoc
TZ=UTC %{__make} -C doc
TZ=UTC make doc
%install
%{__rm} -rf %{buildroot}
%{__make} install DESTDIR="%{buildroot}"
%{__install} -Dp -m0644 rear.cron %{buildroot}%{_sysconfdir}/cron.d/rear
%{make_install}
install -p -d %{buildroot}%{_docdir}/%{name}/
install -m 0644 %{SOURCE1} %{buildroot}%{_docdir}/%{name}/
install -m 0644 %{SOURCE2} %{buildroot}%{_docdir}/%{name}/
install -m 0644 %{SOURCE3} %{buildroot}%{_docdir}/%{name}/
#-- FILES ---------------------------------------------------------------------#
%files
%defattr(-, root, root, 0755)
%doc MAINTAINERS COPYING README.adoc doc/*.txt doc/user-guide/relax-and-recover-user-guide.html
%doc MAINTAINERS COPYING README.adoc doc/*.txt doc/user-guide/*.html
%doc %{_mandir}/man8/rear.8*
%config(noreplace) %{_sysconfdir}/cron.d/rear
%doc %{_docdir}/%{name}/rear.*
%config(noreplace) %{_sysconfdir}/rear/
%config(noreplace) %{_sysconfdir}/rear/cert/
%{_datadir}/rear/
%{_localstatedir}/lib/rear/
%{_sharedstatedir}/rear/
%{_sbindir}/rear
#-- CHANGELOG -----------------------------------------------------------------#
%changelog
* Wed Feb 21 2024 Pavel Cahyna <pcahyna@redhat.com> - 2.6-12
* Sat Jul 20 2024 Pavel Cahyna <pcahyna@redhat.com> - 2.6-25
- Backport PR 3250 to fix useless warning that libsystemd-core requires
additional libraries and ReaR recovery system needs additional libraries
- Backport PR 3242 to fix IPv6 address in nfs:// and sshfs:// BACKUP/OUTPUT_URL
- Backport PR 2576 to remove obsolete FAT16 options to avoid kernel warning
* Sat Feb 24 2024 Pavel Cahyna <pcahyna@redhat.com> - 2.6-24
- Support "export TMPDIR" in user configuration again, print a warning
when this is used - revert commit f464eae2, adapt PR 3163, add commit
b422845f.
Will be supported only until the update to 2.7
* Fri Feb 9 2024 Pavel Cahyna <pcahyna@redhat.com> - 2.6-23
- Resolve libs for executable links in COPY_AS_IS, PR 3073
- Skip invalid disk drives when saving layout PR 3047
* Thu Feb 8 2024 Pavel Cahyna <pcahyna@redhat.com> - 2.6-22
- Do not delete NetBackup logs in case of errors and save
/usr/openv/netbackup/logs to the restored system after a successful recovery
- Add /usr/openv/var to COPY_AS_IS_NBU, fixes an issue seen
with NetBackup 10.2.0.1
* Thu Feb 8 2024 Pavel Cahyna <pcahyna@redhat.com> - 2.6-21
- Support saving and restoring hybrid BIOS/UEFI bootloader, PRs 3145 3136
- make initrd accessible only by root (CVE-2024-23301), PR 3123
* Fri Dec 1 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-20
- Backport PR 3061 to save LVM pool metadata volume size in disk layout
and restore it
- Backport PR 3058 to skip useless xfs mount options when mounting
during recovery, prevents mount errors like "logbuf size must be greater
than or equal to log stripe size"
* Tue Aug 22 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-10
* Fri Aug 25 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-19
- Add patch to force removal of lvmdevices, prevents LVM problems after
restoring to different disks/cloning. Upstream PR 3043
* Tue Aug 22 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-18
- Add patch to start rsyslog and include NBU systemd units
- Apply PR 3027 to ensure correct creation of the rescue environment
when a file is shrinking while being read
- Backport PR 2774 to increase USB_UEFI_PART_SIZE to 1024 MiB
@ -242,64 +264,59 @@ TZ=UTC %{__make} -C doc
- Backport upstream PR 3031: Secure Boot support for OUTPUT=USB
- Correct a mistake done when backporting PR 2691
* Wed Feb 22 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-9
* Wed Feb 22 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-17
- Backport PR2943 to fix s390x dasd formatting
- Require s390utils-{core,base} on s390x
* Sun Jan 15 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-8
* Sun Jan 15 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-16
- Apply PR2903 to protect against colons in pvdisplay output
- Apply PR2873 to fix initrd regeneration on s390x
- Apply PR2431 to migrate XFS configuration files
* Wed Aug 24 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-7
* Thu Aug 25 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-15
- Exclude /etc/lvm/devices from the rescue system to work around a segfault
in lvm pvcreate
* Wed Aug 24 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-14
- Avoid stderr message about irrelevant broken links
- Changes for NetBackup (NBU) 9.x support
* Tue Aug 9 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-6
- Restore usr/share/rear/output/PXE/default/820_copy_to_net.sh
removed in 2.4-19 with rsync refactor.
It is still needed to use a rsync OUTPUT_URL when OUTPUT=PXE and BACKUP=RSYNC
* Tue Aug 9 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-13
- Backport PR2831 - rsync URL refactoring
fixes rsync OUTPUT_URL when different from BACKUP_URL
* Mon Aug 8 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-5
* Mon Aug 8 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-12
- Apply PR2795 to detect changes in system files between backup
and rescue image
- Apply PR2808 to exclude dev/watchdog* from recovery system
- Backport upstream PRs 2827 and 2839 to pass -y to lvcreate instead of one "y"
on stdin
- Apply PR2811 to add the PRE/POST_RECOVERY_COMMANDS directives
- Recommend dosfstools on x86 and aarch64, needed for EFI System Partition
- Recommend dosfstools on x86_64, needed for EFI System Partition
- Backport PR2825 to replace defunct mkinitrd with dracut
- Apply PR2580 to load the nvram module in the rescue environment in order
to be able to set the boot order on ppc64le LPARs
- Backport PR2822 to include the true vi executable in rescue ramdisk
* Sun Feb 27 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-4
* Sun Feb 27 2022 Pavel Cahyna <pcahyna@redhat.com> - 2.6-11
- Apply PR2675 to fix leftover temp dir bug (introduced in backported PR2625)
- Apply PR2603 to ignore unused PV devices
- Apply upstream PR2750 to avoid exclusion of wanted multipath devices
- Remove unneeded xorriso dep on s390x (no ISO image support there)
- Apply upstream PR2736 to add the EXCLUDE_{IP_ADDRESSES,NETWORK_INTERFACES}
options
* Mon Aug 30 2021 Pavel Cahyna <pcahyna@redhat.com> - 2.6-3
- Add patch for better handling of thin pools and other LV types not supported
by vgcfgrestore
Resolves: rhbz1747468
* Mon Aug 16 2021 Pavel Cahyna <pcahyna@redhat.com> - 2.6-2
* Mon Aug 16 2021 Pavel Cahyna <pcahyna@redhat.com> - 2.6-10
- Sync spec changes and downstream patches from RHEL 8 rear-2.6-2
- Fix multipath performance regression in 2.6, introduced by upstream PR #2299.
Resolves: rhbz1993296
* Sat Aug 7 2021 Pavel Cahyna <pcahyna@redhat.com> - 2.6-1
- Rebase to upstream release 2.6 and drop unneded patches.
Add S/390 support.
Resolves: rhbz1983003, rhbz1988493, rhbz1868421
- Add missing dependencies on dhcp-client (see #1926451), file
- Patch documents to be compatible with asciidoc,
we don't have asciidoctor
- On POWER add bootlist & ofpathname to the list of required programs
conditionally (bootlist only if running under PowerVM, ofpathname
always except on PowerNV) - upstream PR2665, add them to package
dependencies
Resolves: rhbz1983013
* Tue May 11 2021 Pavel Cahyna <pcahyna@redhat.com> - 2.4-19
- Backport PR2608:
Fix setting boot path in case of UEFI partition (ESP) on MD RAID
Resolves: rhbz1945869
@ -307,187 +324,65 @@ TZ=UTC %{__make} -C doc
Prevents accidental backup removal in case of errors
Resolves: rhbz1958247
- Fix rsync error and option handling
Fixes metadata storage when rsync user is not root
Resolves: rhbz1930662
* Mon Jan 11 2021 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.4-18
- Fix typo in default.conf
Resolves: #1882060
* Wed Aug 11 2021 Pavel Cahyna <pcahyna@redhat.com> - 2.6-9
- Put TMPDIR on /var/tmp by default, otherwise it may lack space
RHBZ #1988420, upstream PR2664
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 2.6-8
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Jun 30 2021 Pavel Cahyna <pcahyna@redhat.com> - 2.6-7
- Sync spec changes and downstream patches from RHEL 8
- Require xorriso instead of genisoimage
- Add S/390 support and forgotten dependency on the file utility
- Backport upstream code related to LUKS2 support
- Modify the cron command to avoid an e-mail with error message after
ReaR is installed but not properly configured when the cron command
is triggered for the first time
Resolves: #1729499
- Backport upstream code related to LUKS2 support
Resolves: #1832394
- Changes for NetBackup (NBU) support, upstream PR2544
Resolves: #1898080
- Add dependency on dhcp-client, RHBZ #1926451
* Mon Aug 10 2020 Pavel Cahyna <pcahyna@redhat.com> - 2.4-17
- Update the Rubrik patch to include complete PR2445
Resolves: rhbz1867696
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.6-6
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Thu Jun 04 2020 Václav Doležal <vdolezal@redhat.com> - 2.4-16
- Apply upstream PR2373: Skip Longhorn Engine replica devices
Resolves: rhbz1843809
* Fri Feb 26 2021 Christopher Engelhard <ce@lcts.de> - 2.6-5
- Change /lib to /usr/lib in scripts to fix RHBZ #1931112
* Mon Jun 01 2020 Václav Doležal <vdolezal@redhat.com> - 2.4-15
- Apply upstream PR2346: Have '-iso-level 3' option also for ppc64le
Resolves: rhbz1729502
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Jun 01 2020 Václav Doležal <vdolezal@redhat.com> - 2.4-14
- Backport remaining Rubrik related patches.
Related: rhbz1743303
* Wed Sep 23 2020 Christopher Engelhard <ce@lcts.de> - 2.6-3
- Stop auto-creating a cronjob, but ship example cronjob/
systemd timer units in docdir instead (upstream issue #1829)
- Build & ship HTML user guide
- Remove %pre scriptlet, as it was introduced only to fix a
specific upgrade issue with v1.15 in 2014
* Thu May 21 2020 Václav Doležal <vdolezal@redhat.com> - 2.4-13
- Backport upstream PR #2249 to add support for Rubrik backup method.
Resolves: rhbz1743303
* Tue Sep 22 2020 Christopher Engelhard <ce@lcts.de> - 2.6-2
- Backport upstream PR#2469 to fix RHBZ #1831311
* Mon Dec 16 2019 Pavel Cahyna <pcahyna@redhat.com> - 2.4-12
- Backport upstream PR #2293 to use grub-mkstandalone instead of
grub-mkimage for UEFI (ISO image and GRUB_RESCUE image generation).
Avoids hardcoded module lists or paths and so is more robust.
Fixes an issue where the generated ISO image had no GRUB2 modules and
was therefore unbootable. The backport does not add new config settings.
Resolves: rhbz1737042
* Tue Sep 22 2020 Christopher Engelhard <ce@lcts.de> - 2.6-1
- Update to 2.6
- Streamline & clean up spec file
* Mon Nov 18 2019 Pavel Cahyna <pcahyna@redhat.com> - 2.4-11
- Apply upstream PR2122: add additional NBU library path to fix support for
NetBackup 8.
Resolves: rhbz1747393
- Apply upstream PR2021: Be safe against empty docker_root_dir (issue 1989)
Resolves: rhbz1729493, where ReaR can not create a backup in rescue mode,
because it thinks that the Docker daemon is running and hits the problem
with empty docker_root_dir.
- Apply upstream PR2223 and commit 36cf20e to avoid an empty string in the
list of users to clone, which can lead to bash overflow with lots of users
and groups per user and to wrong passwd/group files in the rescue system.
Resolves: rhbz1729495
- Backport of Upstream fix for issue 2035: /run is not mounted in the rescue
chroot, which causes LVM to hang, especially if rebuilding initramfs.
Resolves: rhbz1757488
- Backport upstream PR 2218: avoid keeping build dir on errors
by default when used noninteractively
Resolves: rhbz1729501
- Apply upstream PR2173 - Cannot restore using Bacula method
due to "bconsole" not showing its prompt
Resolves: rhbz1726992
- Backport fix for upstream issue 2187 (disklayout.conf file contains
duplicate lines, breaking recovery in migration mode or when
thin pools are used). PR2194, 2196.
Resolves: rhbz1732308
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jun 4 2019 Pavel Cahyna <pcahyna@redhat.com> - 2.4-10
- Apply upstream patch PR1993
Automatically exclude $BUILD_DIR from the backup
Resolves: rhbz1677733
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Mon Jun 3 2019 Pavel Cahyna <pcahyna@redhat.com> - 2.4-9
- Update fix for bz#1657725. Previous fix was not correct, bootlist was still
invoked only with one partition argument due to incorrect array expansion.
See upstream PR2096, 2097, 2098.
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue May 28 2019 Pavel Cahyna <pcahyna@redhat.com> - 2.4-8
- Apply upstream PR2065 (record permanent MAC address for team members)
Resolves: rhbz1685178
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Tue May 28 2019 Pavel Cahyna <pcahyna@redhat.com> - 2.4-7
- Apply upstream PR2034 (multipath optimizations for lots of devices)
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Mon Jan 14 2019 Pavel Cahyna <pcahyna@redhat.com> - 2.4-6
- Require xorriso instead of genisoimage, it is now the preferred method
and supports files over 4GB in size.
- Apply upstream PR2004 (support for custom network interface naming)
- Backport upstream PR2001 (UEFI support broken on Fedora 29 and RHEL 8)
* Thu Jul 30 2015 Johannes Meixner <jsmeix@suse.de>
- For a changelog see the rear-release-notes.txt file.
* Thu Dec 13 2018 Pavel Cahyna <pcahyna@redhat.com> - 2.4-4
- Backport fixes for upstream bugs 1974 and 1975
- Backport fix for upstream bug 1913 (backup succeeds in case of tar error)
- Backport fix for upstream bug 1926 (support for LACP bonding and teaming)
- Apply upstream PR1954 (record permanent MAC address for bond members)
* Thu Aug 09 2018 Pavel Cahyna <pcahyna@redhat.com> - 2.4-3
- Merge some spec changes from Fedora.
- Apply upstream patch PR1887
LPAR/PPC64 bootlist is incorrectly set when having multiple 'prep' partitions
- Apply upstream patch PR1885
Partition information recorded is unexpected when disk has 4K block size
* Wed Jul 18 2018 Pavel Cahyna <pcahyna@redhat.com> - 2.4-2
- Build and install the HTML user guide. #1418459
* Wed Jun 27 2018 Pavel Cahyna <pcahyna@redhat.com> - 2.4-1
- Rebase to version 2.4, drop patches integrated upstream
Resolves #1534646 #1484051 #1498828 #1571266 #1496518
* Wed Feb 14 2018 Pavel Cahyna <pcahyna@redhat.com> - 2.00-6
- Ensure that NetBackup is started automatically upon recovery (PR#1544)
Also do not kill daemons spawned by sysinit.service at the service's end
(PR#1610, applies to NetBackup and also to dhclient)
Resolves #1506231
- Print a warning if grub2-mkimage is about to fail and suggest what to do.
bz#1492177
- Update the patch for #1388653 to the one actually merged upstream (PR1418)
* Fri Jan 12 2018 Pavel Cahyna <pcahyna@redhat.com> - 2.00-5
- cd to the correct directory before md5sum to fix BACKUP_INTEGRITY_CHECK.
Upstream PR#1685, bz1532676
* Mon Oct 23 2017 Pavel Cahyna <pcahyna@redhat.com> - 2.00-4
- Retry get_disk_size to fix upstream #1370, bz1388653
* Wed Sep 13 2017 Pavel Cahyna <pcahyna@redhat.com> - 2.00-3
- Fix rear mkrescue on systems w/o UEFI. Upstream PR#1481 issue#1478
- Resolves: #1479002
* Wed May 17 2017 Jakub Mazanek <jmazanek@redhat.com> - 2.00-2
- Excluding Archs s390 and s390x
- Related #1355667
* Mon Feb 20 2017 Jakub Mazanek <jmazanek@redhat.com> - 2.00-1
- Rebase to version 2.00
- Resolves #1355667
* Tue Jul 19 2016 Petr Hracek <phracek@redhat.com> - 1.17.2-6
- Replace experimental grep -P with grep -E
Resolves: #1290205
* Wed Mar 23 2016 Petr Hracek <phracek@redhat.com> - 1.17.2-5
- Remove backuped patched files
Related: #1283930
* Wed Mar 23 2016 Petr Hracek <phracek@redhat.com> - 1.17.2-4
- Rear recovery over teaming interface will not work
Resolves: #1283930
* Tue Mar 08 2016 Petr Hracek <phracek@redhat.com> - 1.17.2-3
- Replace experimental grep -P with grep -E
Resolves: #1290205
* Tue Feb 23 2016 Petr Hracek <phracek@redhat.com> - 1.17.2-2
- rear does not require syslinux
- changing to arch package so that syslinux is installed
- Resolves: #1283927
* Mon Sep 14 2015 Petr Hracek <phracek@redhat.com> - 1.17.2-1
- New upstream release 1.17.2
Related: #1059196
* Wed May 13 2015 Petr Hracek <phracek@redhat.com> 1.17.0-2
- Fix Source tag
Related: #1059196
* Mon May 04 2015 Petr Hracek <phracek@redhat.com> 1.17.0-1
- Initial package for RHEL 7
Resolves: #1059196
* Fri Oct 17 2014 Gratien D'haese <gratien.dhaese@gmail.com>
- added the suse_version lines to identify the corresponding OS_VERSION
* Fri Jun 20 2014 Gratien D'haese <gratien.dhaese@gmail.com>
- add %%pre section
* Thu Apr 11 2013 Gratien D'haese <gratien.dhaese@gmail.com>
- changes Source
* Thu Jun 03 2010 Dag Wieers <dag@wieers.com>
- Initial package. (using DAR)