Positional Arguments and Options: Order matters #213

Closed
opened 2019-09-10 20:41:17 +00:00 by Alkac · 4 comments

What I'm trying to do and why

Not sure if it is a feature request or bug relating to the order of how positional parameters are used.

Imagine file with patterns:

$ cat /patterns
P sh
R /home/john
- /home/john/.cache

Then, there is a difference between the following commands.

  1. This is the syntax used by borg docs:
$ borg create --patterns-from /patterns repo::archive /home/john

In this case, borg backs up /home/john directory (and its contents) only once, even that technically the recursive root is stated twice (in patterns and as a positional parameter.)

  1. However, in this syntax used by borgmatic:
$ borg create repo::archive /home/john --patterns-from /patterns 

in this case, borg backs up the directory twice (each file is added twice and deduplicated, obviously).

borg docs

Borg documentation suggest to use options before REPO::ARCHIVE

Borg only supports taking options (-s and --progress in the example) to the left or right of all positional arguments (repo::archive and path in the example), but not in between them:

borg create -s --progress repo::archive path  # good and preferred
borg create repo::archive path -s --progress  # also works
borg create -s repo::archive path --progress  # works, but ugly
borg create repo::archive -s --progress path  # BAD

Additional info

While borg create may be run without [PATH] parameter (as long as -R /path is used in patterns file), it is not possible to delete source_directories in borgmatic's config.yaml (required parameter).

What I would expect

There may be various solutions to this issue (like stating that in config.yaml notes for patterns_from directive), however, it may generally be better if borgmatic places options before REPO::ARCHIVE positional parameters to be consistent with borg recommendation and examples in documentation for each command.

Environment

borgmatic version: 1.3.13-1

borgmatic installation method: AUR Arch package

Borg version: 1.1.10-1

Python version: 3.7.4

operating system and version: Arch Linux x86_64, up-to-date

#### What I'm trying to do and why Not sure if it is a feature request or bug relating to the order of how positional parameters are used. Imagine file with patterns: ``` $ cat /patterns P sh R /home/john - /home/john/.cache ``` Then, there is a difference between the following commands. 1. This is the syntax used by borg docs: ``` $ borg create --patterns-from /patterns repo::archive /home/john ``` In this case, borg backs up /home/john directory (and its contents) only _once_, even that technically the recursive root is stated twice (in patterns and as a positional parameter.) 2. However, in this syntax used by borgmatic: ``` $ borg create repo::archive /home/john --patterns-from /patterns ``` in this case, borg backs up the directory _twice_ (each file is added twice and deduplicated, obviously). ### borg docs Borg documentation suggest to use options before REPO::ARCHIVE _Borg only supports taking options (-s and --progress in the example) to the left or right of all positional arguments (repo::archive and path in the example), but not in between them:_ ``` borg create -s --progress repo::archive path # good and preferred borg create repo::archive path -s --progress # also works borg create -s repo::archive path --progress # works, but ugly borg create repo::archive -s --progress path # BAD ``` ### Additional info While `borg create` may be run without [PATH] parameter (as long as `-R /path` is used in `patterns` file), it is not possible to delete `source_directories` in borgmatic's config.yaml (required parameter). ### What I would expect There may be various solutions to this issue (like stating that in config.yaml notes for `patterns_from` directive), however, it may generally be better if borgmatic places options before REPO::ARCHIVE positional parameters to be consistent with borg recommendation and examples in documentation for each command. #### Environment **borgmatic version:** 1.3.13-1 **borgmatic installation method:** AUR Arch package **Borg version:** 1.1.10-1 **Python version:** 3.7.4 **operating system and version:** Arch Linux x86_64, up-to-date
Owner

it may generally be better if borgmatic places options before REPO::ARCHIVE positional parameters to be consistent with borg recommendation and examples in documentation for each command.

That certainly makes sense to me. Seems like it'd be a pretty easy change to make across the board for all commands.

Thank you for pointing this issue out!

While borg create may be run without [PATH] parameter (as long as -R /path is used in patterns file), it is not possible to delete source_directories in borgmatic’s config.yaml (required parameter).

Does this seem like a desirable thing? Worth filing separately? Or not needed assuming this ticket is fixed?

> it may generally be better if borgmatic places options before REPO::ARCHIVE positional parameters to be consistent with borg recommendation and examples in documentation for each command. That certainly makes sense to me. Seems like it'd be a pretty easy change to make across the board for all commands. Thank you for pointing this issue out! > While borg create may be run without [PATH] parameter (as long as -R /path is used in patterns file), it is not possible to delete source_directories in borgmatic’s config.yaml (required parameter). Does this seem like a desirable thing? Worth filing separately? Or not needed assuming this ticket is fixed?
witten added the
bug
label 2019-09-10 22:40:55 +00:00
Author

I think the latter is a minor issue not worth considering for a separate ticket as long as the former one is fixed. Thanks!

I think the latter is a minor issue not worth considering for a separate ticket as long as the former one is fixed. Thanks!
Owner

Just fixed in master. And it'll be released as part of the next borgmatic release (hopefully soon). Thanks again!

Just fixed in master. And it'll be released as part of the next borgmatic release (hopefully soon). Thanks again!
Owner

And now released as part of borgmatic 1.3.15!

And now released as part of borgmatic 1.3.15!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#213
No description provided.