Hi there, new user on the latest version on Windows. Enjoying restic so far, my complements!
I am using restic in the excellent git for Windows bash terminal.
$ restic version
restic 0.17.1 compiled with go1.23.1 on windows/amd64
My use case is that I want to export tar archives of entire snapshots from various restic repositories. This is useful for existing tooling that confirms the validity of our disaster recovery efforts. So far, I cannot find a way to reliably automate this without first investigating each snapshot.
As an example, this particular repository backs up a saver. The full Windows path is some variant of C:\Users\<USER>\AppData\<...ETC>...\Data
, but full paths are not useful to me so I backup from a relative folder path. The ls
command demonstrates this:
$ restic ls latest
# ...
/Data
/Data/<...VARIOUS FILES...>
Despite restic ls
clearly showing that all paths start with /Data
, I was not able to run restic dump
on this path:
$ restic dump latest '/Data' --archive tar --target export.tar
# ...
Fatal: cannot dump file: path "\\C:" not found in snapshot
I expected restic ls
paths to work in restic dump
, hence my confusion.
Incidentally, this failed command creates a zero-byte export.tar
. You might want to consider that behavior a low-priority bug, considering that it encounters a fatal error before any files are exported? Up to you.
Try as I might, I cannot get restic to “please just export the whole damn snapshot”:
# Same error as above
$ restic dump latest '/' --archive tar --target export.tar
# ...
Fatal: cannot dump file: path "\\C:" not found in snapshot
# Tried using a windows slash instead, slightly different error
$ restic dump latest '\' --archive tar --target export.tar
# ..
Fatal: cannot dump file: path "\\" not found in snapshot
# Tried using a dot
$ restic dump latest '.' --archive tar --target export.tar
# ...
Fatal: cannot dump file: path "\\" not found in snapshot
Eventually I found what it wanted: Data
without a leading slash works!
$ restic dump latest 'Data' --archive tar --target export.tar
# Worked!
$ tar tf export.tar
Data # ...
One small surprise I had is that restic dump
will happily clobber existing files. Considering how other parts of restic are quite cautious, I found that a little incongruous:
$ touch some-file
# Happily clobbers file without confirmation
$ restic dump latest 'Data' --archive tar --target some-file
For now, my workaround to reliably restic dump
a whole snapshot is:
- Investigate the output of
restic ls
- Check if there is a single top-level folder, or multiple
- Remove leading slashes
- Pass those results to
restic dump
I could script that with restic’s --json
flag, but first I wanted to check with this forum that my understanding is correct & that I’m not missing something obvious.
My questions for this thread are:
-
Is the mismatch between paths used by
restic ls
andrestic dump
intentional? How can I understand the difference? -
Is there a way to run
restic dump
reliably on a whole snapshot without looking at things likerestic ls
? -
What is the official restic policy or design on slashes differing between OSes? Does restic consider everything to be POSIX internally? Is this documented?
-
Do you (the devs) want to consider initial
restic dump --target
failures creating a zero-byte tar a bug? -
Do you (the devs) want to consider
restic dump --target
overwriting files without confirmation a bug? Or, maybe document that behavior in--help
?
Thanks!