k8up icon indicating copy to clipboard operation
k8up copied to clipboard

Add "nightly" Schedule Specification

Open cdchris12 opened this issue 3 years ago • 3 comments

Summary

As a user of k8up
I want to be able to allow the controller to schedule backups automatically between 0000 and 0300
So that nightly backups can be automated more efficiently

Context

As a result of the new schedule options, the controller can now automate the timeframe for certain tasks via new schedule specifications like @monthly, @midnight, and @daily. These options are a great addition, but do not allow for the functionality required to run nightly backups at scale, as the @daily option and the @midnight option both run at 0000 and the @daily-random option can schedule a backup at any time of the day with no way to specify a certain time range.

Implementing a new @range option which would function much like the @daily-random function, but with start and end times between two user definable hours would allow for users to let the controller handle exact backup scheduling timeframes whilst still ensuring these backups happen during off-peak time ranges.

Out of Scope

Further links

Schedule documentation: https://github.com/vshn/k8up/blob/master/docs/modules/ROOT/pages/references/schedule-specification.adoc

Acceptance criteria

Given a schedule with a specification of `@range:0-3`
When the controller sees such a value
Then the controller should automatically pick a time to schedule the suggested operation that is between 0000 ( `0 0 * * *` ) and 0300 ( `0 3 * * *` ) .
Given a schedule with a spec `@range:23-3`
When the controller sees such a value
Then it shedules the job between `0 23 * * *` and `0 2 * * *` 
Given a schedule with a spec `@range:22-23`
When the controller sees such a value
Then it schedules the job between `0 22 * * *` and `0 23 * * *`
Given a schedule with an invalid spec `@range:-15-37`
When the controller sees the value
Then consider any minus number a `0`
And consider any number larger than `23` as `23`

Implementation Ideas

  • Initially, it seems like this would be easy enough to implement as a clone of @daily-random, with time gates from the spec instead of 0000 to 2359.
  • As a possible future addition, it could be good to ensure that each automatically scheduled operation does not conflict with other scheduled events of the same type from operations which use this same backup bucket.

cdchris12 avatar Jan 15 '21 18:01 cdchris12

I feel like the definition of @nightly can be very different for many users. For you it's 00:00 - 03:00 for me it would be more like 22:00 - 06:00. So implementing the @nightly as defined here only covers one of many different nightly-ranges.

Maybe we could implement something like @range-random where a user could specify a range within the backups should be randomized. That way users have a powerful way to customize the random schedules generated by k8up.

Kidswiss avatar Jan 18 '21 07:01 Kidswiss

Your solution sounds good to me! It's easy enough to just add some extra variables when specifying a schedule. :)

I do wonder if such a time frame option would be easily compatible with eventual environment task de-duplication as well as collision avoidance between tasks using the same bucket?

cdchris12 avatar Jan 18 '21 08:01 cdchris12

@cdchris12 I'm rewriting your request a bit, to incorporate the information from the comments.

Kidswiss avatar Apr 22 '22 07:04 Kidswiss