Restic: Fatal: wrong password or no key found when try to backup with stdin

Created on 31 Jul 2018  Â·  2Comments  Â·  Source: restic/restic

Output of restic version

restic 0.9.1 compiled with go1.10.3 on linux/amd64

How did you run restic exactly?

pg_dump database | restic -r /tmp/restic-repo backup --stdin --stdin-filename prod.sql

Actual behavior

Error output:

Fatal: wrong password or no key found

Steps to reproduce the behavior

restic -r /tmp/restic-repo init
pg_dump database | restic -r /tmp/restic-repo backup --stdin --stdin-filename prod.sql

Most helpful comment

I think that's how its supposed to work, you can't enter a password, as anything going to stdin will get backed up. Two alternatives are that you can create a file with the password in and then set this:

$ echo "1234" > /my/password/file
$ export RESTIC_PASSWORD_FILE=/my/password/file

or use the '-p' option

$ restic -p /my/password/file backup --stdin ...

All 2 comments

I think that's how its supposed to work, you can't enter a password, as anything going to stdin will get backed up. Two alternatives are that you can create a file with the password in and then set this:

$ echo "1234" > /my/password/file
$ export RESTIC_PASSWORD_FILE=/my/password/file

or use the '-p' option

$ restic -p /my/password/file backup --stdin ...

Oh, thanks for the hint on the issue! I think we can add a message to restic, stating that it reads the password from stdin if it detects that stdin is not a terminal, like this:

$ echo foo | ./restic backup .| cat                                                                restic-password-stdin-message ✱
read password from stdin
Files:           0 new,     0 changed,    51 unmodified
Dirs:            0 new,     0 changed,     0 unmodified
Added to the repo: 0 B
processed 51 files, 23.997 MiB in 0:00
snapshot ca278fd1 saved

It's only shown when stdin is a terminal, otherwise the user is queried for the password normally.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

e2b picture e2b  Â·  4Comments

jpic picture jpic  Â·  3Comments

fbartels picture fbartels  Â·  3Comments

ikarlo picture ikarlo  Â·  4Comments

christian-vent picture christian-vent  Â·  3Comments