[question] Is it possible to run before_backup hook not only once, but everytime a repo starts #320

Closed
opened 2020-05-28 17:47:33 +00:00 by caioau · 7 comments

What I'm trying to do and why

Im backuping up an VPS into a mini pc in my home, but I use port knocking to access the mini pc, so I put the port knocking script into before_backup hook, but I have 2 repos (1 to backup into the internal hdd and another in the external hdd), so when the 2th repo backup starts it fails (bacause the port is now closed).

Can I instruct before_backup to run everytime before starting a repo backup? Or maybe create a new hook called before_repo_backup , not sure.

Thanks very much! I been using borgmatic and it's awesome. Keep up the awesome work.

#### What I'm trying to do and why Im backuping up an VPS into a mini pc in my home, but I use port knocking to access the mini pc, so I put the port knocking script into before_backup hook, but I have 2 repos (1 to backup into the internal hdd and another in the external hdd), so when the 2th repo backup starts it fails (bacause the port is now closed). Can I instruct before_backup to run everytime before starting a repo backup? Or maybe create a new hook called before_repo_backup , not sure. Thanks very much! I been using borgmatic and it's awesome. Keep up the awesome work.
caioau changed title from [question] Is it possible to run before_backup hook not only once, but everytime starts every repo. to [question] Is it possible to run before_backup hook not only once, but everytime a repo starts 2020-05-28 17:49:25 +00:00
Owner

Thank you for filing this ticket, and for the kind words!

I could see adding a hook called before_repo or before_repository. Question though: Would it make sense to run regardless of actions specified (create, prune, check, etc.)? I imagine that for any action that needs to interact with the remote repository, you'd need the port knocking script to run first...?

Thank you for filing this ticket, and for the kind words! I could see adding a hook called `before_repo` or `before_repository`. Question though: Would it make sense to run regardless of actions specified (`create`, `prune`, `check`, etc.)? I imagine that for any action that needs to interact with the remote repository, you'd need the port knocking script to run first...?
Author

Yes, it would be needed to run for any action.

Yes, it would be needed to run for any action.
Owner

Okay, thanks!

Okay, thanks!
witten added the
design finalized
label 2020-05-28 18:05:43 +00:00
Author

ah another cool thing for this feature, is the possibility to pass the repo hostname to the script, to make it more generic, so the repos are in diffrent hosts, something like this:

before_repo: port_knocking_script.sh %h

ah another cool thing for this feature, is the possibility to pass the repo hostname to the script, to make it more generic, so the repos are in diffrent hosts, something like this: before_repo: port_knocking_script.sh %h
Owner

That's a great idea.. I've thought of something similiar with some of the existing hooks. For simplicity's sake, I could see just unconditionally passing in the repository path as the first parameter to the script (no %h needed). And then it's up to the script to do whatever it wants with that.

That's a great idea.. I've thought of something similiar with some of the existing hooks. For simplicity's sake, I could see just unconditionally passing in the repository path as the first parameter to the script (no `%h` needed). And then it's up to the script to do whatever it wants with that.
Owner

Part of this will be implemented once #473 is released. Specifically, all the before_backup, after_backup hooks will run on a per-repository basis, and the full repository path (including hostname) will be able for interpolation as the repository variable.

The one part of this ticket that isn't yet implemented is a general per-repository hook that gets run for all actions (create, prune, etc.).

Part of this will be implemented once #473 is released. Specifically, all the `before_backup`, `after_backup` hooks will run on a per-repository basis, and the full repository path (including hostname) will be able for [interpolation](https://torsion.org/borgmatic/docs/how-to/add-preparation-and-cleanup-steps-to-backups/#variable-interpolation) as the `repository` variable. The one part of this ticket that isn't yet implemented is a general per-repository hook that gets run for all actions (`create`, `prune`, etc.).
Owner

This was implemented a while ago! (It's in borgmatic 1.7.0+.) before_actions/after_actions are the new hooks for this and they run once per configured repository.

This was implemented a while ago! (It's in borgmatic 1.7.0+.) `before_actions`/`after_actions` are the new hooks for this and they run once per configured repository.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#320
No description provided.