0

I've configured a systemd timer for a hourly, daily and weekly backup with rsnapshot on an external HD.

When I'm at work HD it's connected and I've configured rsnapshot.conf with option

no_create_root  1

so that if backup path is not present directory is not created and backup is not done.

My problem is that when the time of the backup is due is when I'm not at work and HD is not connected so there is no rsnapshot run BUT the weekly timer is reset instead to be "retried" next time I reboot the machine (hopefully at work).

This is my timer configuration

[Unit]
Description=rsnapshot weekly backup

[Timer]
OnCalendar=weekly
Persistent=true
Unit=rsnapshot@weekly.service

[Install]
WantedBy=timers.target

and if I grep for a weekly run on

/var/log/messages

There is no evidence of any operation successful or not while a daily or hourly operation is present.

If I ask for timer status

sudo systemctl status rsnapshot-weekly.timer

Oct 24 13:30:35 criniv rsnapshot[10991]: /usr/bin/rsnapshot daily: completed successfully
rsnapshot-weekly.timer - rsnapshot weekly backup
Loaded: loaded (/etc/systemd/system/rsnapshot-weekly.timer; enabled)
Active: active (waiting) since lun 2016-10-24 08:46:21 CEST; 5h 48min ago

That seems that a previous run was successful but it's not. Can you help me to figure out how configure it correctly?

  • Have you tried Mark Stosberg's tutorial on systemd and rsnapshot? – Mark Stosberg Oct 24 '16 at 18:03
  • No, I missed it. I'm going to read it carefully. – Valerio Crini Oct 26 '16 at 3:16
  • It suggest to set a specific date when scheduling weekly backup. I'll try this suggestion but I asked for a solution that didn't use a specific date but a period (weekly in my case). – Valerio Crini Oct 26 '16 at 15:20
  • You should be able to still express a weekly schedule but otherwise use the tips there. – Mark Stosberg Oct 26 '16 at 15:22
  • 1
    I've implemented scheduled weekly backup with a fixed date and it worked. It's not what I was wanted originally but it solves my problem. – Valerio Crini Nov 4 '16 at 10:03
1

As suggested by Mark on timer configuration I changed OnCalendar from Unit section from

[Timer]
OnCalendar=weekly
Persistent=true
Unit=rsnapshot@weekly.service

to

[Timer]
OnCalendar=monday  *-*-* 10:00:00
Persistent=true
Unit=rsnapshot@weekly.service

This it's not exactly what I was searching for but it mitigates my problem. What I was searching for was a tweak to fix

OnCalendar=weekly

behavior that skips backup if machine is down - same problem also if I specify a date as tutorial teaches but I avoided the issue by scheduling a period I know my machine is on.

| improve this answer | |
0

You can create weekly backups with "catchup" runs by using the Persistent= directive in your timer unit file, documented in man systemd.timer.

Persistent=

Takes a boolean argument. If true, the time when the service unit was last triggered is stored on disk. When the timer is activated, the service unit is triggered immediately if it would have been triggered at least once during the time when the timer was inactive. This is useful to catch up on missed runs of the service when the machine was off. Note that this setting only has an effect on timers configured with OnCalendar=.

| improve this answer | |
  • I've already put that parameter in configuration as you can see by my first post. – Valerio Crini Nov 7 '16 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.