Closed DanielVoogsgerd closed 1 year ago
Ah cool, thanks for bringing this to my attention! I wasn't aware of these repo2 commands...
First of all, the @-pair syntax does not work with --repo
. It only selects what sections are being read, and --repo
is usually one of the values in that section.
Right now crestic
is also limited so that it only accepts @-pairs as the first parameter. Everything after is passed to restic
, so you can pass the command and overload other parameters. Breaking with that and allowing it in options like --repo2
would probably result in quite a complication in the codebase, so right now I don't think it is worth it.
Note that the repo@ part does not match to anything but is syntactically required, I might open up an issue about that as well, but this seems to cause more friction for me.
Maybe you are simply misunderstanding the purpose of @-pairs. If you don't need the prefix, just don't use it:
[local]
repo=/srv/restic-repo
and crestic local backup
.
Can you give a concrete usecase in which you'd really need this, and can't solve it in the current system? I.e. if you use the @-pairs differently, you could do
[@local]
repo=/srv/restic-repo
[@local-copy]
repo=/srv/restic-repo-copy
[@local-copy.copy]
repo=/srv/restic-repo
repo2=/srv/restic-repo-copy
and crestic copy repo@local-copy
Thanks for your elaborate response.
Maybe you are simply misunderstanding the purpose of @-pairs. If you don't need the prefix, just don't use it:
I think there is still a place for using split pairs with only the first or the second part.
I agree with the README that:
These split presets are in the format of prefix@suffix and are usually used to separate local location values from remote repo locations
So, for example, when I want to init a repository at one of the locations in the configuration you could use:
crestic @disk init
Which would be quite elegant in my opinion. Right now you can do something similar as you mentioned by duplicating the section so that one section name does not begin with an @, but I think being a bit more leniant with the syntax would make it more expressive. Right now the workaround would be to use a split pair and specifying a non-existing first part of the pair so that it would not match to anything.
For the repeated split pairs I was more thinking along the lines of when a second split pair is encountered --repo
flags would be converted to their --repo2
equivalent. But I understand that this might be a little too much magic which would be quite against the feel/philosophy of the tool.
Thinking about it some more a more elegant and expressive way using the current syntax would be to configure copy like this:
crestic destination@source copy
And then additionally configuring locations as the first pair as well, but with the repo2 equivalent flags:
[destination@.copy]
repo2: /srv/restic-repo-copy
I hope it's somewhat clear what I'm trying to accomplish here :sweat_smile:
I just went through this again and tried
[local@.copy]
repo: local-repo.restic
[@remote.copy]
repo2: remote-repo.restic
when running
env CRESTIC_DRYRUN=1 crestic local@remote copy
it expands to
restic copy --repo2 remote-repo.restic --repo local-repo.restic
that should be somewhat what you want, no?
But I think anything more is beyond what this tool is trying to achieve, so I am closing this, sorry.
I really like what you did with crestic, especially how everything maps neatly onto the arguments of restic. However, as far as I understand it working with commands that use repo2, like copy, can be quite clunky as the @ syntax only works on the --repo, -r flag.
Would it be possible to map a second @-pair to the repo2 equivalent arguments.
For example the docs example for copy would be:
restic -r /srv/restic-repo copy --repo2 /srv/restic-repo-copy
This could be mapped to:
crestic repo@local copy repo@local-copy
with the following config:
Note that the repo@ part does not match to anything but is syntactically required, I might open up an issue about that as well, but this seems to cause more friction for me.
This is the first solution that came to mind, but I'm open to suggestions about alternatives.