Bug 2035872 - Evaluation enhancement of PRE_RECOVERY/POST_RECOVERY/PRE_BACKUP/POST_BACKUP scripts
Summary: Evaluation enhancement of PRE_RECOVERY/POST_RECOVERY/PRE_BACKUP/POST_BACKUP s...
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: rear
Version: 8.5
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Pavel Cahyna
QA Contact: David Jež
Šárka Jana
Depends On: 2111059
TreeView+ depends on / blocked
Reported: 2021-12-28 09:30 UTC by Renaud Métrich
Modified: 2022-11-08 11:09 UTC (History)
3 users (show)

Fixed In Version: rear-2.6-5.el8
Doc Type: Enhancement
Doc Text:
.ReaR adds new variables for executing commands before and after recovery With this enhancement, ReaR introduces two new variables for easier automation of commands to be executed before and after recovery: * `PRE_RECOVERY_COMMANDS` accepts an array of commands. These commands will be executed before recovery starts. * `POST_RECOVERY_COMMANDS` accepts an array of commands. These commands will be executed after recovery finishes. These variables are an alternative to `PRE_RECOVERY_SCRIPT` and `POST_RECOVERY_SCRIPT` with the following differences: * The earlier `PRE_RECOVERY_SCRIPT` and `POST_RECOVERY_SCRIPT` variables accept a single shell command. To pass multiple commands to these variables, you must separate the commands by semicolons. * The new `PRE_RECOVERY_COMMANDS` and `POST_RECOVERY_COMMANDS` variables accept arrays of commands, and each element of the array is executed as a separate command. As a result, providing multiple commands to be executed in the rescue system before and after recovery is now easier and less error-prone. For more information, see the `default.conf` file.
Clone Of:
: 2111059 (view as bug list)
Last Closed: 2022-11-08 10:02:43 UTC
Type: Bug
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github rear rear pull 2735 0 None closed Evaluation enhancement of PRE_RECOVERY/POST_RECOVERY/PRE_BACKUP/POST_BACKUP scripts 2022-07-26 11:55:51 UTC
Github rear rear pull 2811 0 None Merged Add PRE_RECOVERY_COMMANDS and POST_RECOVERY_COMMANDS 2022-06-02 16:07:02 UTC
Red Hat Issue Tracker RHELPLAN-106631 0 None None None 2021-12-28 09:34:26 UTC
Red Hat Product Errata RHBA-2022:7654 0 None None None 2022-11-08 10:02:50 UTC

Description Renaud Métrich 2021-12-28 09:30:27 UTC
Description of problem:

Please backport PR https://github.com/rear/rear/pull/2735 once accepted Upstream.

The current evaluation of the scripts is through "eval ${SCRIPT[@]}" which has many drawbacks, in particular when using array variables, each line must be semi-colon terminated or else the rest will be skipped, e.g.

PRE_RECOVERY_SCRIPT=( 'multipathd' )
PRE_RECOVERY_SCRIPT+=( 'sleep 10' )

results in executing "multipathd sleep 10" instead of expected "multipathd" then "sleep 10".

This enhancement evaluates the scripts item by item, which is more bulletproof and still supports having the script specified as a string variable.

Version-Release number of selected component (if applicable):

All rear released including 2.6

How reproducible:


Comment 1 Pavel Cahyna 2022-01-07 22:36:10 UTC
Hi, thanks for the PR, I left a comment there. The current behavior is indeed a bit silly, but it seems to be what was intended (except for the handling of whitespace in arguments, which is probably not as intended, and with it the whole justification for using shell arrays disappears). So, I think it is better to introduce new variables with a better-defined behavior, and let the old ones slowly die.

Comment 2 Pavel Cahyna 2022-05-05 14:14:22 UTC
We now have a discussion upstream about other changes of semantics of POST_BACKUP. Would it be acceptable to do just the PRE/POST_RECOVERY part for now? Also, your opinion on whether to run the POST_BACKUP commands even after a failed backup is welcome (do you have more real-world scenaria than the one with DBMS stop/start?)

Comment 3 Pavel Cahyna 2022-06-02 16:07:03 UTC
A PR implementing the new syntax for PRE/POST_RECOVERY only has been merged. Is it acceptable to add only that and avoid any additions to PRE/POST_BACKUP ? Note that PR 2735 does not preserve the original semantics of exit task handling in PRE/POST_BACKUP_SCRIPT for PRE/POST_BACKUP_COMMANDS: POST_BACKUP_SCRIPT is executed on error only if PRE_BACKUP_SCRIPT is set, as noted in https://github.com/rear/rear/pull/2735#issuecomment-1145006984, while no such logic exists for POST_BACKUP_COMMANDS.

Comment 4 Renaud Métrich 2022-06-07 05:45:49 UTC
Hi Pavel,

I'm sorry I totally forgot this. Please do what you consider best here.

Comment 14 errata-xmlrpc 2022-11-08 10:02:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (rear bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.