More helpful error message for restic dump

I recently wanted to see the contents of a file and ran this restic command:

restic -r /the/repo dump latest /home/user/.config/tool

The path should have been /home/user/.config/tool/config.json in which case this would have worked as expected. It did not work because the given path is a directory. So this issue is on the user’s side.

I am writing this post, because I could not understand the error message:

Fatal: cannot dump file: stdout is the terminal, please redirect output

What does it want to tell me? Could it check if the path is a directory and say something like

Fatal: cannot dump this path because it is a directory?

“dump” (unlike “restore”) is actually dumping the data itself, so it is meant to be redirected to some target. E.g.

restic -r /the/repo dump latest /home/user/.config/tool > config.tool.restored

Otherwise, since restic does not now about file types, dumped file could be binary and there is a risk of garbage data on the screen, like:

$ cat /usr/bin/env
... and a lot more

:grimacing: I hope it makes sense.

(if you are dumping a folder instead of a file, document says it is dumping as tar or zip file, so you can either do > restored.tar or pass the -a zip parameter to be able to redirect to >

1 Like

I see. For the text file it worked. That’s why I thought the issue is about the directory. I expected some binary data, some restic representation of a directory, a directory listing or an error about directories but not this message.

But dump can actually dump directories as tar files as you pointed out. I could now make it show the output by piping to less (restic ... | less) and file recognizes it as POSIX tar archive.

I would close this or mark as answered if there was a button to close it.

Interesting idea. Since restic can detect if output is terminal then it can explain a bit more, or redirect to --help text.

There should be a “solution” tickbox under messages (for you as the thread owner?).
But maybe that’s something which needs some user privileges, not sure. In any case, case closed :sweat_smile: