autorestic icon indicating copy to clipboard operation
autorestic copied to clipboard

Cron updates timestamp even when backup fails

Open daniel-ferguson opened this issue 6 months ago • 0 comments

Hi! To start with I just wanted to say thanks for maintaining this project, it's made managing backups with restic so much easier for me :smile:

Describe the bug

Even when an autorestic cron run fails during the backup process, the latest cron timestamp (found in .autorestic.lock.yml) is updated.

This is an issue for me because I have cron set to back up daily, and if the autorestic cron attempt happens when my internet is temporarily unavailable (for backblaze), or my removable hard drive is unplugged (for local) then it will refuse to run again that same day with the message: Skipping "<location>", not due yet.

Expected behavior

I would expect that the next autorestic cron command triggered after my internet came back on would run and back up my data.

Environment

  • OS: Linux - Fedora 39
  • Version: 1.7.9

Additional context

I suspect this is because the timestamp is written before the backup even starts, and no error handling is performed on the result of the backup, see: https://github.com/cupcakearmy/autorestic/blob/068121d722c7994f7608f124b71b9a1ecf50ac19/internal/location.go#L439-L442

daniel-ferguson avatar Dec 05 '23 19:12 daniel-ferguson