nils-werner / crestic

Configurable Restic Wrapper

Home Page:https://nils-werner.github.io/crestic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Config for flags that can be used multiple times?

tlc opened this issue · comments

commented

restic backup has 7 flags that can be specified multiple times.

$ restic backup --help 2>&1|grep multiple
  -e, --exclude pattern                  exclude a pattern (can be specified multiple times)
      --exclude-file file                read exclude patterns from a file (can be specified multiple times)
      --exclude-if-present stringArray   takes filename[:header], exclude contents of directories containing filename (except filename itself) if header of that file is as provided (can be specified multiple times)
      --files-from stringArray           read the files to backup from file (can be combined with file args/can be specified multiple times)
      --tag tag                          add a tag for the new snapshot (can be specified multiple times)
  -o, --option key=value          set extended option (key=value, can be specified multiple times)
  -v, --verbose n                 be verbose (specify --verbose multiple times or level n)

I couldn't figure out how to specify multiple uses in the ini file.

I've pushed an update to master branch that allows this, simply use multi-line config values if you want to define an option twice, i.e.

[home.backup]
exclude = file1.txt
    file2.txt
    file3.txt

Does this work for you? Any feedback on this is welcome!

commented

Looks good. Thanks.

It would be great if this were mentioned in the README. I was just about to write an issue but then found this closed one 😄

hey there! took me a while to find this issue as I was struggling to nail the command.

  1. The provided multi-line example is wrong multiple_presets.cfg#L9 because it gets expanded to this: --exclude --exclude config.py --exclude passwords.txt - notice the --exclude flag is duplicated at the beginning. The example provided in this issue, three comments above ^, is correct, but I find it rather ugly. Would you consider omitting the first item if it's empty? Alternatively it would be rather intuitive to just allow flags to be specified multiple times, that was my first attempt, but crestic complained that there's a duplicate key.
  2. Can you please please please document this in readme?
commented

One more vote to document this in README. Was hard to find here :).

@nils-werner, I'm happy to send a PR for the README if that would help?

I'll add it to the readme. Reopening so I don't forget :-)

I've now created some documentation that includes the repeating values syntax.

commented

Nice! Thank you!

This still contains the error that @shark0der mentioned above, doesn't it? I.e.

key:
    val1
    val2

vs.

key: val1
    val2