Discussion:
[rsnapshot-discuss] cron - timing - interval
Masi Osmani
2016-07-06 11:01:20 UTC
Permalink
Hey guys,


as i wrote here https://github.com/rsnapshot/rsnapshot/issues/142 - sam-at-github thx for your answer.


i understand the concept of the retain levels, but maybe i didnt make clear my thoughts.


here is an example for a interval scheme :

##################################################

retain daily 7
retain weekly 4
retain monthly 12


here is the schedule for its interval scheme (crons) :

##################################################

44 2 * * * root rsnapshot daily # mon-sat

27 0 * * 0 root rsnapshot weekly # sun
17 1 1 * * root rsnapshot monthly # first of every month


if i would start my first backup then it results like this :

##################################################

Mon - daily.0

Tue - daily.1

Wed - daily.2

Thu - daily.3

Fri - daily.4

Sat - daily.5


On Sun i see a problem, cron would call first "rsnapshot weekly" (look at cron times), this will cause:


"daily.6 not present (yet), nothing to copy"


because of that behavior weekly.0 is skipped.


My temporarily fix looks like this :

#############################

### rsnapshot-cron

# _________________________ 1. Minute - Minutes after the hour (0-59)
# |
# | ______________________ 2. Hour - 24-hour format (0-23).
# | |
# | | ___________________ 3. Day - Day of the month (1-31)
# | | |
# | | | ________________ 4. Month - Month of the year (1-12)
# | | | |
# | | | | ______________5. Weekday - Day of the week. (0-6, 0 indicates Sunday)
# | | | | |
#__|_____|_____|_____|____|___User___Command_____________________________________________________

20 1 * * 1-6 root rsnapshot sync && rsnapshot daily

48 2 * * 0 root rsnapshot sync && rsnapshot daily && rsnapshot weekly

53 3 1 * * root if [[ -z $( rsnapshot -v -t monthly | grep 'not present (yet), nothing to copy') ]]; then rsnapshot monthly ; fi



As you can see i tried to solve the problem by paying attention to the order of the cron times and by adding the logical AND.


Maybe you can suggest a better solution. My goal is that the chronology of the backups are allways guaranteed concerning the timing.



Regards

Masi

Loading...