Skip to content

Commit

Permalink
Merge pull request #2459 from rear/jsmeix-dd_bs1M-issues_2369_2458
Browse files Browse the repository at this point in the history
Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
cf. #2369
and #2458
  • Loading branch information
jsmeix committed Jul 21, 2020
2 parents 450a669 + 88c7164 commit 6e96a01
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
8 changes: 6 additions & 2 deletions usr/share/rear/backup/BLOCKCLONE/default/500_start_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ case "$(basename ${BLOCKCLONE_PROG})" in
-O $backuparchive $BLOCKCLONE_SOURCE_DEV
;;
(dd)
dd $BLOCKCLONE_PROG_OPTS if=$BLOCKCLONE_SOURCE_DEV \
of=$backuparchive
# Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
# cf. https://github.com/rear/rear/issues/2369 and https://github.com/rear/rear/issues/2458
# Have "bs=1M" before BLOCKCLONE_PROG_OPTS because when BLOCKCLONE_PROG_OPTS
# contains already e.g. "bs=4k" (cf. doc/user-guide/12-BLOCKCLONE.adoc)
# the last of the two "bs=..." settings wins (at least with 'dd' on openSUSE Leap 15.1)
dd bs=1M $BLOCKCLONE_PROG_OPTS if=$BLOCKCLONE_SOURCE_DEV of=$backuparchive
;;
esac

Expand Down
3 changes: 2 additions & 1 deletion usr/share/rear/finalize/Linux-ppc64le/660_install_grub2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ for part in $part_list ; do
# Install GRUB2 on the PPC PReP boot partition if one was found:
if test "$part" ; then
LogPrint "Found PPC PReP boot partition $part - installing GRUB2 there"
# Erase the first 512 bytes of the PPC PReP boot partition:
# Zero out the PPC PReP boot partition
# cf. https://github.com/rear/rear/pull/673
dd if=/dev/zero of=$part
if chroot $TARGET_FS_ROOT /bin/bash --login -c "$grub_name-install $grub2_install_option $part" ; then
# In contrast to the above behaviour when GRUB2_INSTALL_DEVICES is specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ case "$(basename ${BLOCKCLONE_PROG})" in
-O $BLOCKCLONE_SOURCE_DEV $backuparchive
;;
(dd)
dd $BLOCKCLONE_PROG_OPTS of=$BLOCKCLONE_SOURCE_DEV \
if=$backuparchive
# Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
# cf. https://github.com/rear/rear/issues/2369 and https://github.com/rear/rear/issues/2458
# Have "bs=1M" before BLOCKCLONE_PROG_OPTS because when BLOCKCLONE_PROG_OPTS
# contains already e.g. "bs=4k" (cf. doc/user-guide/12-BLOCKCLONE.adoc)
# the last of the two "bs=..." settings wins (at least with 'dd' on openSUSE Leap 15.1)
dd bs=1M $BLOCKCLONE_PROG_OPTS of=$BLOCKCLONE_SOURCE_DEV if=$backuparchive
;;
esac

Expand Down
14 changes: 9 additions & 5 deletions usr/share/rear/restore/NETFS/default/400_restore_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ if test -f $TMP_DIR/backup.splitted ; then
ProgressInfo ""
LogPrint "Processing $backup_file_name ..."
# The actual feeder program:
dd if="$backup_file_path" of="$FIFO"
# Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
# cf. https://github.com/rear/rear/issues/2369 and https://github.com/rear/rear/issues/2458
dd if="$backup_file_path" of="$FIFO" bs=1M
else
StopIfError "$backup_file_name could not be found on the $vol_name medium!"
fi
Expand Down Expand Up @@ -142,14 +144,16 @@ for restore_input in "${RESTORE_ARCHIVES[@]}" ; do
if [ -s $TMP_DIR/restore-exclude-list.txt ] ; then
BACKUP_PROG_OPTIONS+=( "--exclude-from=$TMP_DIR/restore-exclude-list.txt" )
fi
# Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
# cf. https://github.com/rear/rear/issues/2369 and https://github.com/rear/rear/issues/2458
if is_true "$BACKUP_PROG_CRYPT_ENABLED" ; then
Log "dd if=$restore_input | $BACKUP_PROG_DECRYPT_OPTIONS BACKUP_PROG_CRYPT_KEY | $BACKUP_PROG --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C $TARGET_FS_ROOT/ -x -f -"
dd if=$restore_input | { $BACKUP_PROG_DECRYPT_OPTIONS "$BACKUP_PROG_CRYPT_KEY" ; } 2>/dev/null | $BACKUP_PROG --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C $TARGET_FS_ROOT/ -x -f -
Log "dd if=$restore_input bs=1M | $BACKUP_PROG_DECRYPT_OPTIONS BACKUP_PROG_CRYPT_KEY | $BACKUP_PROG --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C $TARGET_FS_ROOT/ -x -f -"
dd if=$restore_input bs=1M | { $BACKUP_PROG_DECRYPT_OPTIONS "$BACKUP_PROG_CRYPT_KEY" ; } 2>/dev/null | $BACKUP_PROG --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C $TARGET_FS_ROOT/ -x -f -

else
Log "dd if=$restore_input | $BACKUP_PROG --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C $TARGET_FS_ROOT/ -x -f -"
Log "dd if=$restore_input bs=1M | $BACKUP_PROG --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C $TARGET_FS_ROOT/ -x -f -"

dd if=$restore_input | $BACKUP_PROG --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C $TARGET_FS_ROOT/ -x -f -
dd if=$restore_input bs=1M | $BACKUP_PROG --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C $TARGET_FS_ROOT/ -x -f -
fi
;;
(rsync)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ IsInArray "yes" "${RECREATE_USERS_GROUPS[@]}" || return

[ -z "$TMPDIR" ] && TMPDIR=$(mktemp -d -t rear_405.XXXXXXXXXXXXXXX)

# Extract the passwd, shadow and group files from our backup to our rescue /tmp
# so we can use those files to repopulate the users in the target system:
# Do not show the BACKUP_PROG_CRYPT_KEY value in a log file
# where BACKUP_PROG_CRYPT_KEY is only used if BACKUP_PROG_CRYPT_ENABLED is true
# therefore 'Log ... BACKUP_PROG_CRYPT_KEY ...' is used (and not '$BACKUP_PROG_CRYPT_KEY')
Expand All @@ -31,13 +33,14 @@ IsInArray "yes" "${RECREATE_USERS_GROUPS[@]}" || return
# because it is more important to not leak out user secrets into a log file
# than having stderr error messages when a confidential command fails
# cf. https://github.com/rear/rear/issues/2155
# Extract the passwd, shadow and group files from our backup to our rescue /tmp so we can use those files to repopulate the users in the target system
# Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
# cf. https://github.com/rear/rear/issues/2369 and https://github.com/rear/rear/issues/2458
if is_true "$BACKUP_PROG_CRYPT_ENABLED" ; then
dd if=$backuparchive | \
dd if=$backuparchive bs=1M | \
{ $BACKUP_PROG_DECRYPT_OPTIONS "$BACKUP_PROG_CRYPT_KEY" ; } 2>/dev/null | \
$BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C $TMPDIR -x -f - etc/passwd etc/shadow etc/group
else
dd if=$backuparchive | \
dd if=$backuparchive bs=1M | \
$BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C $TMPDIR -x -f - etc/passwd etc/shadow etc/group
fi

Expand Down
16 changes: 10 additions & 6 deletions usr/share/rear/restore/YUM/default/410_restore_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ if test -f $TMP_DIR/backup.splitted ; then
ProgressInfo ""
LogPrint "Processing $backup_file_name ..."
# The actual feeder program:
dd if="$backup_file_path" of="$FIFO"
# Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
# cf. https://github.com/rear/rear/issues/2369 and https://github.com/rear/rear/issues/2458
dd if="$backup_file_path" of="$FIFO" bs=1M
else
StopIfError "$backup_file_name could not be found on the $vol_name medium!"
fi
Expand Down Expand Up @@ -124,16 +126,18 @@ for restore_input in "${RESTORE_ARCHIVES[@]}" ; do
fi
fi
if [ -s $TMP_DIR/restore-exclude-list.txt ] ; then
LogPrint "Copying restore exlusion file from $TMP_DIR/restore-exclude-list.txt to $TARGET_FS_ROOT/tmp"
LogPrint "Copying restore exlusion file from $TMP_DIR/restore-exclude-list.txt to $TARGET_FS_ROOT/tmp"
cp -a $TMP_DIR/restore-exclude-list.txt $TARGET_FS_ROOT/tmp
BACKUP_PROG_OPTIONS+=( --exclude-from=/tmp/restore-exclude-list.txt )
fi
# Let 'dd' read and write up to 1M=1024*1024 bytes at a time to speed up things
# cf. https://github.com/rear/rear/issues/2369 and https://github.com/rear/rear/issues/2458
if is_true "$BACKUP_PROG_CRYPT_ENABLED" ; then
Log "dd if=$restore_input | $BACKUP_PROG_DECRYPT_OPTIONS BACKUP_PROG_CRYPT_KEY | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C / -x -f -"
dd if=$restore_input | { $BACKUP_PROG_DECRYPT_OPTIONS "$BACKUP_PROG_CRYPT_KEY" ; } 2>/dev/null | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C / -x -f -
Log "dd if=$restore_input bs=1M | $BACKUP_PROG_DECRYPT_OPTIONS BACKUP_PROG_CRYPT_KEY | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C / -x -f -"
dd if=$restore_input bs=1M | { $BACKUP_PROG_DECRYPT_OPTIONS "$BACKUP_PROG_CRYPT_KEY" ; } 2>/dev/null | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C / -x -f -
else
Log "dd if=$restore_input | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C / -x -f -"
dd if=$restore_input | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C / -x -f -
Log "dd if=$restore_input bs=1M | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose ${BACKUP_PROG_OPTIONS[@]} ${BACKUP_PROG_COMPRESS_OPTIONS[@]} -C / -x -f -"
dd if=$restore_input bs=1M | chroot $TARGET_FS_ROOT/ $BACKUP_PROG --acls --preserve-permissions --same-owner --block-number --totals --verbose "${BACKUP_PROG_OPTIONS[@]}" "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" -C / -x -f -
fi
;;
(rsync)
Expand Down

0 comments on commit 6e96a01

Please sign in to comment.