Closed jjakob closed 2 years ago
Any commands specified in the run_⚹_backup settings are only run with the Borg create command. If I understand your situation, you need to run commands before almost every Borg command. Is that correct? Specifically, you would want to mount the repository before the first Borg command is run, and the umount command after the last Borg command is run.
Yes. Although I already wrote a wrapper script to achieve that, it might be useful for other people.
I have added two new settings, run_before_borg and run_after_borg. They allow you to run a command or commands before the first and after the last calls to Borg. Hopefully, that is what you were looking for. Would you please try it out and make sure it meets expectations. It is not on PyPI yet, but you can get it from this GitHub repository (version 1.30.1).
Thank you, I don't need the feature any more as I worked around it with my own shell wrapper script. I may try it in the future if I need it again.
You might consider switching to the the Emborg implementation as it will only run your extra commands before and after running Borg itself. If you use a script, your extra commands will be run every time you run Emborg even if Borg would not be run. For example, 'emborg due' does not run Borg. Neither does the configs or log commands.
I use run_before_first_backup and run_after_last_backup to create a LVM snapshot of the root filesystem and mount it, unmount and delete it at the end, and also mount and unmount the remote repository location. This causes emborg to error after
borg create
as it runs the post-backup script immediately after, before it runsborg list
, which means the repository is no longer there.It means I need to move the pre/post scripts out of emborg config into a separate script. It's no problem for me, but it would maybe make more sense to run the post-backup script after all other commands, or make it configurable, as there is a good use-case for running commands right after create but before list, check, prune, ..., for example starting services back up. Or maybe it could be a separate command like "run_last" and leave run_after{,_last}_backup as-is.
This is my test config: