vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.48k stars 1.37k forks source link

Issue with schedule cron definition #6513

Closed pea-io closed 12 months ago

pea-io commented 1 year ago

What steps did you take and what happened:

I want to create a schedule that run every 4 days. I made the following

jupyterhub-workspace   Enabled   2023-07-10 11:04:23 +0200 CEST   15 0 */4 * *   96h0m0s      n/a       app.kubernetes.io/name notin (postgresql)   false

The schedule is never started.

I made the following change to the cron expression: @every 96h and this one works.

What did you expect to happen: I expect that my schedule runs every 4 days

Environment:

Vote on this issue!

This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.

draghuram commented 1 year ago

We (at CloudCasa) are checking this.

nilesh-akhade commented 1 year ago

The cron expression 15 0 */4 * * means the backup should run, every 4th day of the month, starting from day 1. - Check next values on this page.

first at 2023-07-01 00:15:00 UTC then at 2023-07-05 00:15:00 UTC then at 2023-07-09 00:15:00 UTC then at 2023-07-13 00:15:00 UTC then at 2023-07-17 00:15:00 UTC

Ranges and steps can be combined e.g. */2 signifies starting at the minimum for the relevant field then every 2 e.g. 0 for minutes( 0,2...58), 1 for days and months (1,3 ... 11), etc - serverfault

The schedule was created on 2023-07-10 09:04:23 UTC, hence first backup of this schedule should run on 2023-07-13 00:15:00 UTC = 2023-07-13 02:15:00 CEST. Can you please confirm, if the backup is not created on the expected time?

Please note that Velero itself does not parse cron expressions. Instead, it calculates the time at which the backup should run by passing the cron expression string to the external library robfig/cron.

draghuram commented 1 year ago

Thanks @nilesh-akhade. @pea-io, Can the issue be closed?

qiuming-best commented 1 year ago

@nilesh-akhade Thanks for your help, I'm not quite sure about this

first at 2023-07-01 00:15:00 UTC
then at 2023-07-05 00:15:00 UTC
then at 2023-07-09 00:15:00 UTC
then at 2023-08-13 00:15:00 UTC
then at 2023-08-17 00:15:00 UTC

why the next of 2023-07-09 00:15:00 UTC is 2023-08-13 00:15:00 UTC? May it be 2023-07-13 00:15:00 UTC? July, not August?

nilesh-akhade commented 1 year ago

sorry for typo,its july not august

nilesh-akhade commented 1 year ago

@qiuming-best I think it is not the issue with Velero. Just that we were expecting schedules with cron 15 0 */4 * * to run a backup on the 4th day of the month. But it will run on the 1st and 5th day of the month. Which is valid as per cron documentation.

pea-io commented 1 year ago

Hello. Yes we can close the issue. Thanks :)