When running as a normal user, automatically use ~/.config/borgmatic/config.yaml #444

Closed
opened 2021-08-30 11:01:30 +00:00 by JohnLines · 6 comments

What I'm trying to do and why

I have system backups from desktop and NFS server running via borgmatic, but want to back up key files to another repository. Some of those files are on the desktop and some on the NFS server, and these are not readable by root on the desktop, but all these key files are readable by my normal user.

I am doing this by supplying -c ~/.config/borgmatic/config.yaml as an argument to borgmatic, but a potential improvement would be that if /etc/borgmatic/config.yaml is unreadable due to permission denied, then to look for a user config file and use that if it exists and the command line argument is not supplied.

Note that everything works as expected by supplying the configuration file when needed. This is a suggestion to make things easier for users without root or sudo access to set up their own backups a little more smoothly

Other notes / implementation ideas

This could also apply to generate-borgmatic-config and valiadate-borgmatic-config.

Environment

borgmatic version:

1.5.12-2

borgmatic installation method:

Debian package, but briefly tried pip install on a test system

Borg version:

borg 1.1.16

Python version:

Python 3.9.2

operating system and version:

Debian bullseye

#### What I'm trying to do and why I have system backups from desktop and NFS server running via borgmatic, but want to back up key files to another repository. Some of those files are on the desktop and some on the NFS server, and these are not readable by root on the desktop, but all these key files are readable by my normal user. I am doing this by supplying -c ~/.config/borgmatic/config.yaml as an argument to borgmatic, but a potential improvement would be that if /etc/borgmatic/config.yaml is unreadable due to permission denied, then to look for a user config file and use that if it exists and the command line argument is not supplied. Note that everything works as expected by supplying the configuration file when needed. This is a suggestion to make things easier for users without root or sudo access to set up their own backups a little more smoothly #### Other notes / implementation ideas This could also apply to generate-borgmatic-config and valiadate-borgmatic-config. #### Environment **borgmatic version:** 1.5.12-2 **borgmatic installation method:** Debian package, but briefly tried pip install on a test system **Borg version:** borg 1.1.16 **Python version:** Python 3.9.2 **operating system and version:** Debian bullseye

Hi @JohnLines
borgmatic --help shows

Configuration filenames or directories, defaults to: /etc/borgmatic/config.yaml /etc/borgmatic.d $HOME/.config/borgmatic/config.yaml $HOME/.config/borgmatic.d

So renaming $HOME/.config/borgmatic to $HOME/.config/borgmatic.d does the trick.

Best regards

Hi @JohnLines `borgmatic --help` shows ``` Configuration filenames or directories, defaults to: /etc/borgmatic/config.yaml /etc/borgmatic.d $HOME/.config/borgmatic/config.yaml $HOME/.config/borgmatic.d ``` So renaming `$HOME/.config/borgmatic` to `$HOME/.config/borgmatic.d` does the trick. Best regards
Owner

@JohnLines, could you provide some more detail about the permission denied error you're getting when you run borgmatic and it's probing for configuration files? When I try making my /etc/borgmatic/config.yaml file unreadable to a non-root user, and then create ~/.config/borgmatic/config.yaml in a non-root user's home directory that is readable, borgmatic consumes that user configuration file just fine without error. I've tried this on both borgmatic master and 1.5.12 (which you're using).

Maybe this is something specific to NFS or a mounted filesystem?

@JohnLines, could you provide some more detail about the permission denied error you're getting when you run borgmatic and it's probing for configuration files? When I try making my `/etc/borgmatic/config.yaml` file unreadable to a non-root user, and then create `~/.config/borgmatic/config.yaml` in a non-root user's home directory that *is* readable, borgmatic consumes that user configuration file just fine without error. I've tried this on both borgmatic master and 1.5.12 (which you're using). Maybe this is something specific to NFS or a mounted filesystem?
witten added the
question / support
label 2022-03-05 23:55:53 +00:00
Author

I tried renaming my config from .config/borgmatic/config.yaml to .config/borgmatic.d/config.yaml - and have the same symptoms, but investigating further, running

borgmatic -v 2 info

I actually get the info (and it shows my config files are being read) and the issue actually shows at the end at

------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
All archives:               15.08 MB             15.14 MB              9.16 MB
                       Unique chunks         Total chunks
Chunk index:                      27                   39
RemoteRepository: 221 B bytes sent, 3.08 kB bytes received, 5 messages sent
terminating with success status, rc 0

summary:
/etc/borgmatic.d/offsite.yaml: Error parsing configuration file
[Errno 13] Permission denied: '/etc/borgmatic.d/offsite.yaml'
/home/john/.config/borgmatic.d/config.yaml: Successfully ran configuration file

Need some help? https://torsion.org/borgmatic/#issues

so the issue is not, as I had thought, at the start, parsing the files, but at the end.

If I supply a config file, by running as

borgmatic -v 2 -c .config/borgmatic/config.yaml info

then I do not get an error message. It may be specific to something which is done as a tidy up stage only when running an offsite repository.

I tried renaming my config from .config/borgmatic/config.yaml to .config/borgmatic.d/config.yaml - and have the same symptoms, but investigating further, running `borgmatic -v 2 info` I actually get the info (and it shows my config files are being read) and the issue actually shows at the end at ``` ------------------------------------------------------------------------------ Original size Compressed size Deduplicated size All archives: 15.08 MB 15.14 MB 9.16 MB Unique chunks Total chunks Chunk index: 27 39 RemoteRepository: 221 B bytes sent, 3.08 kB bytes received, 5 messages sent terminating with success status, rc 0 summary: /etc/borgmatic.d/offsite.yaml: Error parsing configuration file [Errno 13] Permission denied: '/etc/borgmatic.d/offsite.yaml' /home/john/.config/borgmatic.d/config.yaml: Successfully ran configuration file Need some help? https://torsion.org/borgmatic/#issues ``` so the issue is not, as I had thought, at the start, parsing the files, but at the end. If I supply a config file, by running as `borgmatic -v 2 -c .config/borgmatic/config.yaml info` then I do not get an error message. It may be specific to something which is done as a tidy up stage only when running an offsite repository.
Owner

Aha! I have a repro now. The trick was putting the unreadable configuration file in /etc/borgmatic.d/ instead of /etc/borgmatic/. Now, to figure out what to do about it...

Aha! I have a repro now. The trick was putting the unreadable configuration file in `/etc/borgmatic.d/` instead of `/etc/borgmatic/`. Now, to figure out what to do about it...
witten added
bug
and removed
question / support
labels 2022-03-08 06:11:10 +00:00
Owner

Okay, this has been fixed in borgmatic master by treating permissions errors when loading configuration files as warnings instead of errors. Example:

test.borg: Creating archive
Creating archive at "test.borg::test-2022-03-08T10:11:58.398272"

summary:
/etc/borgmatic.d/netouchezpas.yaml: Insufficient permissions to read configuration file
/home/user/.config/borgmatic/config.yaml: Successfully ran configuration file

Thanks for reporting this! It'll be released as part of the next borgmatic release.

Okay, this has been fixed in borgmatic master by treating permissions errors when loading configuration files as warnings instead of errors. Example: ``` test.borg: Creating archive Creating archive at "test.borg::test-2022-03-08T10:11:58.398272" summary: /etc/borgmatic.d/netouchezpas.yaml: Insufficient permissions to read configuration file /home/user/.config/borgmatic/config.yaml: Successfully ran configuration file ``` Thanks for reporting this! It'll be released as part of the next borgmatic release.
Owner

Released in borgmatic 1.5.24.

Released in borgmatic 1.5.24.
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#444
No description provided.