New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for issue 2200: support new use-case for BLOCKCLONE backup method… #2201
Conversation
… by attempting to unmount device before backup/restore.
@@ -622,7 +622,8 @@ umount_mountpoint() { | |||
Log "Unmounting '$mountpoint'" | |||
umount $v $mountpoint >&2 | |||
if [[ $? -eq 0 ]] ; then | |||
return 0 | |||
echo 0 | |||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From plain looking at the code here I think in general
all 'is_something' testing functions
should not provide the result as a string on stdout
but as usual via the exit code return value so that a testing function
could be used as usual by calling
is_something && ...
is_something || ...
if is_something ...
if ! is_something ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsmeix I think that this should become subject of separate PR, to avoid mixing topics ...
@gozora FYI: |
I'll take a look as time permits (most probably during this weekend) ... V. |
@@ -622,7 +622,8 @@ umount_mountpoint() { | |||
Log "Unmounting '$mountpoint'" | |||
umount $v $mountpoint >&2 | |||
if [[ $? -eq 0 ]] ; then | |||
return 0 | |||
echo 0 | |||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsmeix I think that this should become subject of separate PR, to avoid mixing topics ...
@@ -632,11 +633,13 @@ umount_mountpoint() { | |||
Log "Forced unmount of '$mountpoint'" | |||
umount $v -f $mountpoint >&2 | |||
if [[ $? -eq 0 ]] ; then | |||
return 0 | |||
echo 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that this will not cause trouble elsewhere ?
umount_mountpoint() is called by umount_url() which is quite heavily used across Rear:
usr/share/rear/restore/YUM/default/980_umount_YUM_dir.sh:9:umount_url $BACKUP_URL $BUILD_DIR/outputfs
usr/share/rear/restore/DUPLICITY/default/980_unmount_duplicity_path.sh:8: umount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs
usr/share/rear/verify/YUM/default/980_umount_YUM_dir.sh:8:umount_url $BACKUP_URL $BUILD_DIR/outputfs
usr/share/rear/verify/DUPLICITY/default/980_unmount_duplicity_path.sh:8: umount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs
usr/share/rear/output/default/980_umount_output_dir.sh:11:umount_url $OUTPUT_URL $BUILD_DIR/outputfs
usr/share/rear/output/PXE/default/800_copy_to_tftp.sh:72: umount_url $PXE_TFTP_URL $BUILD_DIR/tftpbootfs
usr/share/rear/output/PXE/default/810_create_pxelinux_cfg.sh:107: umount_url $PXE_TFTP_URL $BUILD_DIR/tftpbootfs
usr/share/rear/lib/global-functions.sh:570:umount_url() {
usr/share/rear/backup/BORG/default/900_umount_usb.sh:9: umount_url usb://$USB_DEVICE $borg_dst_dev
usr/share/rear/backup/DUPLICITY/default/980_unmount_duplicity_path.sh:8: umount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs
usr/share/rear/backup/NETFS/default/980_umount_NETFS_dir.sh:7:umount_url $BACKUP_URL $BUILD_DIR/outputfs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @gozora
You're right, of course. My apologies for missing this. I looked for calls to umount_mountpoint()
throughout the scripts, but missed the fact that it could also be called by other functions.
I'll revert this change and adapt my own code accordingly.
# try to remount it before leaving | ||
if [ "$umount_res" = "0" ]; then | ||
LogPrint "Trying to remount $mp" | ||
mount $v $mp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work only if $mp is listed in /etc/fstab. If you really want to mount it back, you should record device, mount point and options prior unmounting and use there date here. Something like:
mount $v -o $orig_opt $orig_dev $orig_mpt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was aware of the fact that it would only work for mountpoints defined in /etc/fstab
. I took the view that anything not present there would be transient anyway and that silently failing to remount it was acceptable behaviour -- if far from ideal.
But the approach you suggest is better by far, so I'll try to implement that ;-)
Re-align with trunk/HEAD prior to re-test with updated scripts post review.
… by attempting to unmount device before backup/restore. Now takes review comments into consideration.
Updated code to fulfil both suggestions by @gozora. Short comment about fixes in
All of this does nothing to address the (valid) remark of @jsmeix about the behaviour of Regarding testing:
Branch |
# save mount parameters for later | ||
local mount_cmd=$(build_remount_cmd $mp) | ||
umount_mountpoint $mp | ||
umount_res=$? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use correct indentation of previous 3 lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
disk=$1 | ||
[ -z "$disk" ] && echo 1 | ||
local disk=$1 | ||
[ -z "$disk" ] && echo 0 && return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! ;-)
# try unmount | ||
if [ ! -z "$mp" ]; then | ||
umount_mountpoint $mp | ||
umount_res=$? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use correct indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@petroniusniger thanks for updated PR. Thanks! V. |
… by attempting to unmount device before backup/restore. Use correct indentation.
@petroniusniger many thanks for contributing this new functionality and respective documentation to ReaR! V. |
… by attempting to unmount device before backup/restore.
Type:Enhancement
Impact: Normal
Reference to related issue (URL): New use-case for BLOCKCLONE backup method #2200
How was this pull request tested?
site.conf.txt
base_system.conf.txt
products_backup.conf.txt
BLOCKCLONE_TRY_UNMOUNT
is set to "yes"dd
commandBACKUP_PROG_EXCLUDE
/dev/vg00/lvol4
) is successfully unmounted prior to issuing thedd
command, which overwrites the recreated encrypted filesystem with the original LUKS keys and all the filesystem dataBrief description of the changes in this pull request:
BLOCKCLONE_TRY_UNMOUNT
indefault.conf
, including short documentation500_start_clone.sh
now use existing global functionumount_mountpoint()
to try and unmount the source device ifBLOCKCLONE_TRY_UNMOUNT
is set to "yes". It obtains the mount point through a new global function calledget_mountpoint()
500_start_clone.sh
proceeds as before, issuing a warning message that the backup has been taken while the source device was mounted500_start_clone.sh
attempts to re-mounted it before exiting400_restore_clone.sh
now implements the same checks and unmount attempt as500_start_clone.sh
. It does NOT try to remount the target device at the end, but issues a warning message insteadumount_mountpoint()
: return value now visible by calling scriptis_device_mounted()
: local variables now defined aslocal
get_mountpoint()
BLOCKCLONE
use-case in the User Guide, chapter 12