Support user directory expansion everywhere #422

Open
opened 2021-05-30 20:09:01 +00:00 by Alexander-Shukaev · 3 comments

Apart from source_directories, none of the configuration options seem to support tilde (~). That is such paths are passed through as is to borg or otherwise acted upon by borgmatic without applying os.path.expanduser. Would be nice to have this feature applied to paths coming from configuration file in general. Perhaps normalizing (sanitizing) paths is also a good idea.

Apart from `source_directories`, none of the configuration options seem to support tilde (`~`). That is such paths are passed through as is to `borg` or otherwise acted upon by `borgmatic` without applying `os.path.expanduser`. Would be nice to have this feature applied to paths coming from configuration file in general. Perhaps normalizing (sanitizing) paths is also a good idea.
Owner

This seems reasonable to me, but I'm curious: Are there specific options where you'd like to see expansion applied? Candidates I'm seeing:

  • patterns_from
  • excludes_from
  • borgmatic_source_directory
  • temporary_directory
  • borg_*_directory
  • repositories and check_repositories: Already expands ~ implicitly for remote repositories due to SSH being used. I suppose it'd be handy to expand for local repository paths too?
  • PostgreSQL ssl_* paths.

Ones I'd probably omit:

  • patterns: Would require annoying parsing, as it's not just plain paths.
  • encryption_passcommand: May require parsing so as not to expand command arguments, too.
  • hooks: Same reason.

Let me know your thoughts. Thanks!

This seems reasonable to me, but I'm curious: Are there specific options where you'd like to see expansion applied? Candidates I'm seeing: * `patterns_from` * `excludes_from` * `borgmatic_source_directory` * `temporary_directory` * `borg_*_directory` * `repositories` and `check_repositories`: Already expands `~` implicitly for remote repositories due to SSH being used. I suppose it'd be handy to expand for local repository paths too? * PostgreSQL `ssl_*` paths. Ones I'd probably omit: * `patterns`: Would require annoying parsing, as it's not just plain paths. * `encryption_passcommand`: May require parsing so as not to expand command arguments, too. * `hooks`: Same reason. Let me know your thoughts. Thanks!

encryption_passcommand: May require parsing so as not to expand command arguments, too.

Though, that's exactly the use case I'm interested in: I have a setup with one special user doing backups, maintaining all data necessary for borg in its home directory and I store passwords there as well. The entire home is stored on an encrypted ZFS, which gets mounted manually, so it's somewhat safe. Therefore, my passcommand looks like the following right now:

encryption_passcommand: cat /home/ams_d_bak_borg/.config/borg/passwds/hosts

While it would be a little easier to have the following instead:

encryption_passcommand: cat ~/.config/borg/passwds/hosts

Slightly less typing and things are better prepared against additional backup users or a renamed user or a relocated home directory or alike. cat is even used in the official borg-docs, so supporting ~ for its arguments makes sense to me.

> encryption_passcommand: May require parsing so as not to expand command arguments, too. Though, that's exactly the use case I'm interested in: I have a setup with one special user doing backups, maintaining all data necessary for borg in its home directory and I store passwords there as well. The entire home is stored on an encrypted ZFS, which gets mounted manually, so it's somewhat safe. Therefore, my passcommand looks like the following right now: encryption_passcommand: cat /home/ams_d_bak_borg/.config/borg/passwds/hosts While it would be a little easier to have the following instead: encryption_passcommand: cat ~/.config/borg/passwds/hosts Slightly less typing and things are better prepared against additional backup users or a renamed user or a relocated home directory or alike. `cat` is even used in the official borg-docs, so supporting `~` for its arguments makes sense to me.
Owner

Thanks, that example is helpful. It sounds like it's actually the command arguments that you want expanded! So the way I could see this working is to split the value of encryption_passcommand (and other options that are passed to Borg via environment variables), expand each individual command/argument in case there are tildes, and then join them back together. I think that would achieve what you're looking for.

Thanks, that example is helpful. It sounds like it's actually the command arguments that you want expanded! So the way I could see this working is to split the value of `encryption_passcommand` (and other options that are passed to Borg via environment variables), expand each individual command/argument in case there are tildes, and then join them back together. I think that would achieve what you're looking for.
witten added the
good first issue
label 2023-03-27 19:05:36 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
3 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#422
No description provided.