KenKundert / emborg

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

Dry run option doesn't work for `emborg check --repair` #73

Closed kalekundert closed 11 months ago

kalekundert commented 1 year ago

Borg warns not to run the repair command unless you know what you're doing, since it can cause data loss, so I wanted to use the dry run option to see the command before running it. However, the -d flag seems to have no effect in this case:

$ emborg -dn check --repair
reading: /home/kale/.config/emborg/settings
reading: /home/kale/.config/emborg/home
running check command
running avendesora to access passphrase.
/home/kale/.config/avendesora/config: reading.
/home/kale/.config/avendesora/hashes: reading.
/home/kale/.config/avendesora/accounts_files: reading.
/home/kale/.config/avendesora/key.gpg: reading.
/home/kale/.config/avendesora/accounts.gpg: reading.
Setting BORG_PASSPHRASE.
Borg-related environment variables: {
    'BORG_CHECK_I_KNOW_WHAT_I_AM_DOING': 'YES',
    'BORG_PASSPHRASE': '<redacted>',
    'BORG_DISPLAY_PASSPHRASE': 'no',
}
running in: /home/kale/sandbox
running:
    borg \
        list \
        --lock-wait 5 \
        --remote-path borg1 \
        --umask 77 \
        --json \
        <redacted>
Unsetting BORG_PASSPHRASE.
Borg exit status: 0
Borg stdout:
    <redacted>

running avendesora to access passphrase.
/home/kale/.config/avendesora/accounts.gpg: reading.
Setting BORG_PASSPHRASE.
Borg-related environment variables: {
    'BORG_CHECK_I_KNOW_WHAT_I_AM_DOING': 'YES',
    'BORG_DISPLAY_PASSPHRASE': 'no',
    'BORG_PASSPHRASE': '<redacted>',
}
running in: /home/kale/sandbox

Running Borg check command ...
running:
    borg \
        check \
        --lock-wait 5 \
        --remote-path borg1 \
        --umask 77 \
        --repair \
        <redacted>
This is a potentially dangerous function.
check --repair might lead to data loss (for kinds of corruption it is not
capable of dealing with). BE VERY CAREFUL!

Type 'YES' if you understand this and want to continue: YES (from BORG_CHECK_I_KNOW_WHAT_I_AM_DOING)

Also, unless you use the --narrate option, the dry run option doesn't seem to print out the commands that would be executed. This doesn't make sense to me: isn't the whole point of a dry run to see the commands that would be run? Nothing else is supposed to happen, so if the commands aren't displayed, isn't the whole thing a no-op?

KenKundert commented 11 months ago

The Borg check command does not support the --dry-run option.

However, it seems like commands that modify the repository but do not support the --dry-run option should not run if --dry-run is requested. So I have modified Emborg so it does not run either ‘check --repair´ or ‘compact’ if --dry-run is requested.

I am not convinced that --dry-run should imply --narrate. If you run without --narrate and want to see the details of how the Borg commands are run, you can always run ‘emborg log’ to see the contents of the log file.

KenKundert commented 11 months ago

The latest release (1.38) contains a fix to this issue.