KenKundert / emborg

Interactive command line interface to Borg Backup
GNU General Public License v3.0
94 stars 8 forks source link

passcommand config directive #33

Closed mpilgrim8 closed 4 years ago

mpilgrim8 commented 4 years ago

Hi,

I can't seem to get the "passcommand" config directive to work as it does with plain Borg itself, but perhaps I am doing something incorrectly that is Emborg-specific, but wasn't sure if it was a bug? passcommand = 'gpg -qd /home/user/.store-auth.gpg'

I've always had this same setup working with plain Borg itself, as well as with Restic and Rclone using these env vars:

BORG_PASSCOMMAND=gpg -qd /home/user/.store-auth.gpg
RCLONE_PASSWORD_COMMAND=gpg -qd /home/user/.store-auth.gpg
RESTIC_PASSWORD_COMMAND=gpg -qd /home/user/.store-auth.gpg

So it works fine with plain Borg and others, but not with Emborg (neither the "BORG_PASSCOMMAND" env var, nor the explicit Emborg "passcommand" config directive). Everything else with Emborg works fine, so long as I don't use any encryption. But with encryption, I have to use plain Borg directly.

I get this error with verbose enabled:

$ emborg -vc vault init
emborg error: Cannot determine the encryption passphrase.

The log largely says the same:

failure detected:
    Cannot determine the encryption passphrase.
emborg error: Cannot determine the encryption passphrase.
emborg: terminates with status 2 on Tuesday, 17 March 2020 at 11:32:27 AM EDT.

I get the same behavior on both Linux (Manjaro) and MacOS (Catalina/10.15), both with the same Emborg/Borg versions:

$ emborg version
emborg version: 1.15.0 (2020-03-06) [Python 3.8.1].

$ borg --version
borg 1.1.10
KenKundert commented 4 years ago

I really appreciate the great bug report and apologize for the slip up. I was easily able to replicate and fix the error. I have uploaded the new version to github (version 1.15.2). I will be adding some more tests before I upload to pypi, but I should do that in the next few days.

Thank you!

KenKundert commented 4 years ago

I'd like to wait for you to try out the new version before I promote it to pypi. So if you do test it please let me know the result, and if you plan to wait for pyip, please let me know that too.

mpilgrim8 commented 4 years ago

Hi -- thanks for the very fast response! I had it installed via PIP on MacOS and the Arch Linux AUR on Manjaro Linux, but I just did a local/user install via Git repo to test it.

It works, although I have a question on one minor detail. If I hard-code the file path like this: passcommand = 'gpg -qd /home/user/.store-auth.gpg' ...it works:

$ emborg -c vault list
vault-2020-03-17T15:16:18

But if I try to abstract it with "{home_dir}" like this: passcommand = 'gpg -qd {home_dir}/.store-auth.gpg' ...it fails:

$ emborg -c vault list
emborg error: borg list:
    gpg: can't open '{home_dir}/.store-auth.gpg': No such file or directory
    gpg: decrypt_message failed: No such file or directory
    passcommand supplied in BORG_PASSCOMMAND failed: Command '['gpg', '-qd', '{home_dir}/.store-auth.gpg']' returned non-zero exit status 2.

I am using the "{home_dir}" parameter successfully elsewhere in the main config file: default_mount_point = '{home_dir}/Downloads/restore'

...but it doesn't seem to work here. Or is parameter interpolation not supposed to work in the "passcommand" circumstance?

Thanks!

KenKundert commented 4 years ago

Oh, that is odd. I used

    passcommand = 'cat {config_dir}/passphrase'

in my tests and it worked fine. I think Borg used the error message from cat as the passphrase and did not notice that the exit status was nonzero. Any way, it is fixed now if you want to give it another try.

mpilgrim8 commented 4 years ago

Works perfectly! Thanks again! I tested it on both Linux and MacOS, and both work flawlessly.

KenKundert commented 4 years ago

I have done a release and updated pypi. Latest version is 1.16. Thank you so much for your help.