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
Request: ability to run pre/post hooks on a push job #394
Comments
This feature requests and reasonable and should be fairly easy to implement for beginner. A few questions: What metadata will you need in the hook script? Also: I suppose your use case is sending from a pool that doesn't support OpenZFS encryption into one that does? |
(To get an impression of the metadata that's available on the post-edge, run |
For my particular use case, I don't need any metadata at this time, but I could see some of it being useful in the future. Maybe providing items such as the state and errors of the job would allow a script to have better error handling.
In my scenario, I would expect the job to fail as the encrypted dataset on the remote side would not be reachable or the dataset is not mounted.
Correct.
|
As @problame pointed out in #395 the post hook feature requested by this issue could as well be used to send emails after a job finished executing.
@problame Is there a way to make |
That'd be addressed by #297 (rewrite of the terminal status UI). |
We'd likely provide the output of |
You mean if I could work on implementing this feature request for job hooks? |
That PR implements a better terminal UI and coincidentally brings the ability to render the current But the hooks code is pretty easy to follow as well. And a lot less code to worry about. So yes, I'd recommend you taking a look! |
I'd also find this very helpful so I'm adding my use case here. On success running a script that pings https://healthchecks.io so that I get alerted if backups don't run for some reason. In that use case I wouldn't need any particular info for the script, only for the script to run on success (or if it were to run on success or failure then an env var to easily tell the difference). Update for anyone else in this situation: I've written a little script to check if a backup has been received recently + setup systemd to run it periodically: /usr/local/sbin/check-backups-occurred.sh #!/bin/bash
dataset="$1"
timeToCheckForSnapshotsAfterHumanReadable="$2"
endpointToPingOnSuccess="$3"
endpointToPingOnFailure="$4"
timeToCheckForSnapshotsAfter=$(date --date "$timeToCheckForSnapshotsAfterHumanReadable" +'%s')
timeOfLastSnapshot=$(sudo zfs list -Hp -t snapshot -r -o creation -s creation "$dataset" | tail -1)
if [ $timeOfLastSnapshot -gt $timeToCheckForSnapshotsAfter ]; then
/usr/bin/curl -fsS -m 10 --retry 5 -o /dev/null "$endpointToPingOnSuccess"
else
/usr/bin/curl -fsS -m 10 --retry 5 -o /dev/null "$endpointToPingOnFailure"
fi /etc/systemd/system/check-zrepl-backups-occurred.service [Unit]
Description=Reports whether a recently backup has successfully occurred
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/check-backups-occurred.sh "your/dataset/to/check" "11 minutes ago" "https://hc-ping.com/uuid-of-your-check" "https://hc-ping.com/uuid-of-your-check/fail" /etc/systemd/system/check-zrepl-backups-occurred.timer [Unit]
Description=Periodically check that zrepl backups have occurred
[Timer]
OnBootSec=10min
OnUnitActiveSec=10min
Persistent=true
[Install]
WantedBy=timers.target |
(FYI I have an unfinished branch that refactors the snapshotting code to support |
I'd use this functionality to attach / import a zfs backup drive that is usually offline except during backups. The pre hook would import the drive and the post hook export it again and put the drive to sleep. |
I'll try to get the cron syntax stuff cleared away asap, so that people can start hacking on this if they want. |
The issue that tracks the cron snapshotting work is #554 |
The aforementioned snapper refactor & cron support has been released in zrepl 0.6. So, if anyone wants to work on this feature (=generic pre-post hooks for snapshotting & replication) I'm happy to review PRs. |
I have a remote machine configured as a 'sink' to an encrypted dataset. I'd like this dataset to unmounted and locked when the data is at rest. At the moment, I have a cron job that mounts and unlocks the dataset remotely prior to waking up the push job. What I would like is the ability to run pre and post command prior to/after running the job. I see something similar in issue #74 for snapshots.
The text was updated successfully, but these errors were encountered: