Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): Add hooks #1218

Merged
merged 53 commits into from
Oct 5, 2024
Merged

feat(config): Add hooks #1218

merged 53 commits into from
Oct 5, 2024

Conversation

aawsome
Copy link
Member

@aawsome aawsome commented Aug 30, 2024

This PR adds run-before, run-after, run-failure and run-finally hooks for:

  • all commands in the [global.hooks] config profile section
  • commands accessing the repository in the [repository.hooks] config profile section
  • the backup command specifically in the [backup.hooks] config profile section
  • specific backup sources in the [backup.snapshots.hooks] section

Note: This PR includes only calling the given commands. If there is the wish for supplying information to the commands (env variables or parameter substitution), this should be covered by a separate feature request/PR.

closes #902

Copy link
Contributor

@nardoor nardoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this feature deserves:

  • an integration test in some way
  • a page in the cargo book docs

src/commands/backup.rs Outdated Show resolved Hide resolved
src/commands/backup.rs Outdated Show resolved Hide resolved
src/commands/backup.rs Outdated Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
@aawsome aawsome changed the title feat: Add run-before and run-after hooks feat: Add hooks Sep 1, 2024
src/config.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/commands/backup.rs Outdated Show resolved Hide resolved
@aawsome
Copy link
Member Author

aawsome commented Sep 22, 2024

@nardoor A use case could be:

[repository]
repository = "/mnt/repo/

[repository.hooks]
run-before = ["mount /mnt"]
run-finally = ["umount /mnt"]

which would simply mount and umount a (maybe external) drive before and after each rustic operation. Now, when copying to such a repository, we would like to run the hooks too.

(updated to repository.hook; after this is introduced, it is the better place to use such hooks)

src/commands/copy.rs Outdated Show resolved Hide resolved
@aawsome
Copy link
Member Author

aawsome commented Sep 24, 2024

I rebased this to main (merging main into it was getting too complicated)..

I'd like to add [repository.hooks] as suggested - I think I can do it this evening. Then this PR will be ready, from my side.

@simonsan simonsan added this to the NEXT milestone Sep 24, 2024
Copy link
Contributor

@simonsan simonsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First iteration for text grammar in docs. Will review again, when the other changes have been pushed.

config/README.md Outdated Show resolved Hide resolved
config/README.md Outdated Show resolved Hide resolved
config/README.md Outdated Show resolved Hide resolved
config/README.md Outdated Show resolved Hide resolved
config/README.md Outdated Show resolved Hide resolved
src/commands/backup.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@simonsan simonsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits regarding docs

config/README.md Outdated Show resolved Hide resolved
config/README.md Outdated Show resolved Hide resolved
src/commands/backup.rs Outdated Show resolved Hide resolved
config/README.md Outdated Show resolved Hide resolved
src/commands/backup.rs Outdated Show resolved Hide resolved
@simonsan simonsan changed the title feat: Add hooks feat(config): Add hooks Sep 25, 2024
Signed-off-by: simonsan <[email protected]>
Signed-off-by: simonsan <[email protected]>
Signed-off-by: simonsan <[email protected]>
Signed-off-by: simonsan <[email protected]>
Copy link
Contributor

@simonsan simonsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@simonsan simonsan added this pull request to the merge queue Oct 5, 2024
Merged via the queue into main with commit cb3903b Oct 5, 2024
25 checks passed
@simonsan simonsan deleted the hooks branch October 5, 2024 02:15
github-merge-queue bot pushed a commit that referenced this pull request Oct 9, 2024
## 🤖 New release
* `rustic-rs`: 0.9.1 -> 0.9.2 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.9.2](v0.9.1...v0.9.2)
- 2024-10-09

### Added

- *(config)* Add hooks
([#1218](#1218))

### Other

- *(deps)* update rustic_core
([#1309](#1309))
- build and publish docker image on release
([#1297](#1297))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

Co-authored-by: rustic-release-plz[bot] <182542030+rustic-release-plz[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-config Area: Related to the config file functionality and format A-ui-ux Area: Related to user interfaces and user experience C-enhancement Category: New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Per source hooks in the config file
4 participants