I use Borgmatic for backups to a remote server using a systemd system unit (i.e. as root) so I can back up both /etc and /home/hook in one go.
But when I sudo borgmatic mount, I cannot read the mountpoint as a normal user due to permissions.
I tried, and failed, so far:
changing the permissions of the mountpoint
changing the permissions of /etc/borgmatic/* – won’t work, because borg(matic) for security reasons fails if the ssh key therein is shared with any other users
using sudo borgmatic mount --mount-point /mnt/backup_mnt/ --options uid=1000,gid=1000
If you want to run borgmatic on a schedule with privileged access to your files, then you should install borgmatic as the root user by running the following commands:
sudo pipx ensurepath
sudo pipx install borgmatic
Check whether this worked with:
sudo su -
borgmatic --version
If borgmatic is properly installed, that should output your borgmatic version. And if you’d also like sudo borgmatic to work, keep reading!
If you only want to run borgmatic as a non-root user (without privileged file access) or you want to make sudo borgmatic work so borgmatic runs as root, then install borgmatic as a non-root user by running the following commands as that user:
pipx ensurepath
pipx install borgmatic
This should work even if you’ve also installed borgmatic as the root user.
Check whether this worked with:
borgmatic --version
If borgmatic is properly installed, that should output your borgmatic version. You can also try sudo borgmatic --version if you intend to run borgmatic with sudo. If that doesn’t work, you may need to update your sudoers secure_path option.