[Docs] Clarify execution order of shell commands in same borgmatic step #1099
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#1099
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
What order do multiple
command:entries run in when they are for the same borgmatic step?Example:
Note both commands run
after: configuration, but the last one only runs when state isfinish, whereas the first runs in all states.Is it guaranteed in this case that
start_services.shwill run beforeservices_remote_backup? That is, for a given borgmatic step, do multiplecommandsentries for that step run in the order specified in the config file?Background
In my particular case the concern is that
services_remote_backup.pyis lengthy and slow (usesrcloneon my borg repo), and I do not want to delaystart_services.shwhile the remote backup could take hours. However I also do not want to perform a remote backup if any borg steps fail (i.e.,states: [finish]), and I want borgmatic to fail and send a message to healthchecks.io if the remote backup fails (hence runningafter: configurationand notafter: everything). Services should be started again regardless of if borgmatic succeeds (i.e., all states).Analysis
I suspect they are guaranteed to run in order given in the config because
load_configurationrelies on ruamel.yaml which claims it:But I wanted to double check that the maintainers intend to preserve this config-based order behavior in the future before I rely on it.
I suggest clarifying this in the preparation and cleanup steps docs page, https://torsion.org/borgmatic/docs/how-to/add-preparation-and-cleanup-steps-to-backups/
Kudos
Thank you so much for making borgmatic, which has saved my rear on at least a dozen occasions.
Great question! Hooks of the same "step" run in the order as defined in the configuration file. The way it works is:
commands:values, once parsed, are filtered down based on the current state. So if the current state being evaluated isfinish, then only command hooks implicitly or explicitly matching that state are used. The original ordering is maintained during this filtering step.run:commands is executed in turn.I'll leave this ticket open to document this (intentional) behavior. And I'm glad to hear borgmatic is working out for you!
Added to docs. Should be deployed shortly!