XDG directories #562

Closed
opened 2022-07-09 19:36:22 +00:00 by pikeas · 6 comments

It would be nice if Borgmatic supported the XDG spec (~/.config, ~/.local, etc). There's a Python package that can be used to enable this: https://github.com/ActiveState/appdirs

It would be nice if Borgmatic supported the XDG spec (`~/.config`, `~/.local`, etc). There's a Python package that can be used to enable this: https://github.com/ActiveState/appdirs
Owner

Thanks for filing this! By default, borgmatic already looks in ~/.config/borgmatic/config.yaml and ~/.config/borgmatic.d/ for configuration files. And the ~/.config prefix is customizable via the standard XDG_CONFIG_HOME environment variable. Is the idea that you'd like other paths to be used by default on non-Linux OSes, e.g. MacOS?

And for ~/.local, is the the thinking that's where the existing ~/.borgmatic user data would be stored instead?

Thanks for filing this! By default, borgmatic already looks in `~/.config/borgmatic/config.yaml` and `~/.config/borgmatic.d/` for configuration files. And the `~/.config` prefix is customizable via the standard `XDG_CONFIG_HOME` environment variable. Is the idea that you'd like other paths to be used by default on non-Linux OSes, e.g. MacOS? And for `~/.local`, is the the thinking that's where the existing `~/.borgmatic` user data would be stored instead?
Author

And for ~/.local, is the the thinking that's where the existing ~/.borgmatic user data would be stored instead?

Yes, sorry for the late reply. XDG_DATA_HOME (defaulting to ~/.local/share) is the XDG-compliant directory for user-specific app data. It would be nice-to-have if borgmatic fully implemented XDG.

> And for `~/.local`, is the the thinking that's where the existing `~/.borgmatic` user data would be stored instead? Yes, sorry for the late reply. `XDG_DATA_HOME` (defaulting to `~/.local/share`) is the XDG-compliant directory for user-specific app data. It would be nice-to-have if borgmatic fully implemented XDG.
Author

There's also XDG_DATA_STATE_HOME, depending on whether Borgmatic's checks/ is considered "user data" or "user state".

There's also `XDG_DATA_STATE_HOME`, depending on whether Borgmatic's `checks/` is considered "user data" or "user state".
Owner

I apologize for the delay here. I think this would be a good change in terms of standardization. The main difficulty is that the ~/.borgmatic path currently gets encoded into database backup archives in the form of dump file paths. So if changing those paths (either implicitly by default or explicitly with an option), the database restore logic might need to be updated to probe both paths within a backup archive.

Note that there is an existing borgmatic_source_directory that configures this ~/.borgmatic directory, and changing that will just unceremoneously break restores of any existing backups. However this is a comment warning of this above the option.

I apologize for the delay here. I think this would be a good change in terms of standardization. The main difficulty is that the `~/.borgmatic` path currently gets encoded into database backup archives in the form of dump file paths. So if changing those paths (either implicitly by default or explicitly with an option), the database restore logic might need to be updated to probe both paths within a backup archive. Note that there is an existing `borgmatic_source_directory` that configures this `~/.borgmatic` directory, and changing that will just unceremoneously break restores of any existing backups. However this is a comment warning of this above the option.
Owner

Relevant reference: https://wiki.archlinux.org/title/XDG_Base_Directory

Also see #838 for a related ticket.

EDIT: #638 is also related.

Relevant reference: https://wiki.archlinux.org/title/XDG_Base_Directory Also see #838 for a related ticket. EDIT: #638 is also related.
Owner

Released in borgmatic 1.9.0!

There were several changes made as part of this:

  • #562: Deprecate the "borgmatic_source_directory" option in favor of "user_runtime_directory" and "user_state_directory".
  • #562: BREAKING: Move the default borgmatic streaming database dump and bootstrap metadata directory from ~/.borgmatic to /run/user/$UID/borgmatic, which is more XDG-compliant. You can override this location with the new "user_runtime_directory" option. Existing archives with database dumps at the old location are still restorable.
  • #562, #638: Move the default check state directory from ~/.borgmatic to ~/.local/state/borgmatic. This is more XDG-compliant and also prevents these state files from getting backed up (unless you explicitly include them). You can override this location with the new "user_state_directory" option. After the first time you run the "check" action with borgmatic 1.9.0, you can safely delete the ~/.borgmatic directory.
Released in borgmatic 1.9.0! There were several changes made as part of this: * #562: Deprecate the "borgmatic_source_directory" option in favor of "user_runtime_directory" and "user_state_directory". * #562: BREAKING: Move the default borgmatic streaming database dump and bootstrap metadata directory from ~/.borgmatic to /run/user/$UID/borgmatic, which is more XDG-compliant. You can override this location with the new "user_runtime_directory" option. Existing archives with database dumps at the old location are still restorable. * #562, #638: Move the default check state directory from ~/.borgmatic to ~/.local/state/borgmatic. This is more XDG-compliant and also prevents these state files from getting backed up (unless you explicitly include them). You can override this location with the new "user_state_directory" option. After the first time you run the "check" action with borgmatic 1.9.0, you can safely delete the ~/.borgmatic directory.
Sign in to join this conversation.
No Milestone
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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