-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Improve systemd units #498
base: master
Are you sure you want to change the base?
Conversation
btrbk supports hourly backups, so it makes sense for the timer to run hourly, too. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
It does not make sense for the timer or the service to be started (the latter when done so manually) when neither of the two default config files exists. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
systemd’s `AccuracySec` is mainly there in order to allow it to coalescing wake-ups for multiple timers. It’s default of `1min` minute should be enough for this. Using its `RandomizedDelaySec` in order to spread load from e.g. multiple sources that would all perform backups to one target, wouldn’t really make much sense either. Either, the value would need to be quite large, thereby making backups/snapshots too wobbly, or it wouldn’t be effective as at least the backups typically take quite some time. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing!
I'm happy to get some feedback about the systemd units, as I don't use it myself and thus don't see what the implications are.
I will gladly merge that, please have a look at my comments first
@@ -1,6 +1,8 @@ | |||
[Unit] | |||
Description=btrbk backup | |||
Documentation=man:btrbk(1) | |||
ConditionPathExists=|@CONFDIR@/btrbk/btrbk.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not using systemd myself, and my knowledge is a bit limited here (and no, not going to read through all the docs, all those options are one of the reasons for me not to use systemd).
This sounds like a good thing to have. does that mean that the service will not fail if the config file does not exist, even if you start it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, AFAIU, it should not fail (that would require an AssertPathExists
).
@@ -1,9 +1,10 @@ | |||
[Unit] | |||
Description=btrbk daily backup | |||
ConditionPathExists=|@CONFDIR@/btrbk/btrbk.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea to set this in the timer as well? a user might want to override the service with ExecStart=/bin/btrbk run -c some_other_config
, which would somehow break the timer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... TBH, I'm not exactly sure how "bad" it is to run the time and let just the service not run because of the conditional.
Probably not at all, and at most it would be "conceptually" ugly, i.e. when the timer is considered to have been fired, but the service actually didn't.
But even this may not be considered that way by systemd experts.
On could argue, that if a user wants to override the .service
he could as well just also override the .timer
.
So.. yeah... I have no real strong opinion about this.
|
||
[Timer] | ||
OnCalendar=daily |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think daily is a good default. Some want it hourly, some daily, and I know (at least one) doing it minutely ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forget about that commit... it was late in the night and I was pretty dumb ^^
I completely forgot that the times in the retention policies don't determine how often the tool runs, but how long the snapshots/etc. are kept... so hourly
would be really bad.
It could however make sense, if somewhere we add the proper systemd way on how to override (described in systemd.unit(5)) the time, namely by adding a file:
/etc/systemd/system/btrbk.timer.d/foo.conf
with just what shall be overridden:
[Timer]
OnCalendar=hourly
|
||
[Timer] | ||
OnCalendar=daily | ||
AccuracySec=10min |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure myself why I set this, must have read something when initially playing around with btrbk and systemd. Guess the idea was to tell the timer it's ok to be delayed a bit, as there might be other concurrent btrbk timers running (e.g. with different config and execution times)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well then it depends:
Was your idea to spread the time when these fire off (to not cause all load at the same time)? Then RandomizedDelaySec=
would be the appropriate setting, AFAIU.
Otherwise, I, personally would say, 1min
(default) would be enough.
Actually if you give system "so much time" just to fold multiple runs... it would rather cause more load (because more btrbks may run at the same time).
I could update the commit with whatever you like in the end. (The OnCaleder
thing goes away of course)
594fc6d
to
dac6350
Compare
Regarding That is, my backup system is a 'set it and forget it' type of program for me, so if the config suddenly disappears I likely wouldn't notice anything went wrong unless systemd notifies me of services failing, which it sounds like this would prevent? I imagine that is true for other people as well so I'm sure if this is a 'good default' to push on people. If |
Hey.
Some ideas…
Not so sure about the last commit, since I haven’t found why you had put
AccuracySec
in at the first place. So if there was a good reason for it, just skip that commit.Thanks,
Chris.