Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified prep/default/035_valid_backup_methods.sh to make it work more predictable and fail-safe, cf. #2353 (comment)
- Loading branch information
Showing
1 changed file
with
9 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
|
||
# For "rear mkbackup" and also for "rear mkrescue" (also the latter | ||
# because for most external backup methods only "rear mkrescue" is used) | ||
# check what BACKUP methods are mentioned in the form BACKUP=method in default.conf | ||
# and error out when a BACKUP method is not found this way in default.conf | ||
# For "rear mkbackup" and also for "rear mkrescue" | ||
# ( also the latter because for most external backup methods only "rear mkrescue" | ||
# is used because most external backup methods do not implement making a backup | ||
# but only implement to restore a backup see 'BACKUP SOFTWARE INTEGRATION' in "man rear" ) | ||
# check that the BACKUP method implements a matching backup restore method | ||
# i.e. check that a usr/share/rear/restore/$BACKUP directory exists | ||
# and error out when a BACKUP method seems to not support a backup restore | ||
# to ensure that the user cannot specify a non-working BACKUP in /etc/rear/local.conf | ||
# and to ensure that each implemented BACKUP method is mentioned in default.conf | ||
# to have a minimum documentation about what BACKUP methods are implemented in ReaR | ||
# see https://github.com/rear/rear/issues/914 | ||
# and https://github.com/rear/rear/issues/159 | ||
# and https://github.com/rear/rear/issues/2337#issuecomment-596471615 | ||
|
||
local backup_method | ||
local valid_backup_methods=() | ||
|
||
# That 'grep|cut|awk' pipe may find more words than actually valid backup methods | ||
# e.g. assume default.conf contains "using BACKUP=QQQ does not work" | ||
# and it may not find an actually valid backup method | ||
# e.g. assume a valid backup method FOO is only mentioned as "use BACKUP=FOO with BACKUP_URL" | ||
# so a more fail-safe method to autodetect actually valid backup methods may be needed in the future: | ||
for backup_method in $( grep 'BACKUP=' $SHARE_DIR/conf/default.conf | grep -v '_' | cut -d= -f2 | awk '{print $1}' | sort -u ) ; do | ||
valid_backup_methods+=( "$backup_method" ) | ||
done | ||
|
||
if ! grep -q "$BACKUP" <<< $( echo ${valid_backup_methods[@]} ) ; then | ||
Error "The BACKUP method '$BACKUP' is not known to ReaR." | ||
if ! test -d "$SHARE_DIR/restore/$BACKUP" ; then | ||
Error "The BACKUP method '$BACKUP' is not supported (no $SHARE_DIR/restore/$BACKUP directory)" | ||
fi | ||
|
e98c8ad
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 commit fixes
#2352
e98c8ad
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.
Thic commit is a precondition for the fix of
#2351