cupcakearmy / autorestic

Config driven, easy backup cli for restic.
https://autorestic.vercel.app/
Apache License 2.0
1.16k stars 68 forks source link

Cron updates timestamp even when backup fails #343

Open daniel-ferguson opened 7 months ago

daniel-ferguson commented 7 months ago

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

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