Suggestion: Validate location after executing before hooks
Currently, if you have a location with a given file path that doesn't exist at the time of executing autorestic, backups will fail, even when the file will exist after before hooks are run.
locations:
test-location:
from:
- /file/does/not/yet/exist
hooks:
before: touch /file/does/not/yet/exist
...
stat /file/does/not/yet/exist: no such file or directory
Error: 1 errors were found
In this situation, before and after hooks do not run at all.
While it's feasible to create an empty version of this file in advance of executing autorestic, it does require the sort of manual intervention and custom scripting that autorestic otherwise resolves.
I second this as I just wanted to report it as a bug (which it is, IMO). My use-case is that I do btrfs snapshot in before hook. Autorestic fails unless I do the first snapshot manually before the first backup, and I cannot delete the snapshot in after, otherwise it throws an error on next run.
It is not a big deal in my case, althought it took me about half an hour to realize where the problem lies, and it is a bit inconsistent with expectations of when before is executed.
I'll have a crack at creating a PR for this.
My use case is to use a hook to mount the backup source location that contains the "from" directory -- that directory doesn't exist until that mount completes, and the "before" hook runs after checking that all the "from" directories in the location exist, hence that hook is too late.