-
-
Notifications
You must be signed in to change notification settings - Fork 787
Description
/kind enhancement
When creating full system backups one must usually run Borg as root
to avoid permission issues. However, it might be undesirable to store these backups as root, as people often prefer storing backups in known places (like /var/backups
) owned by dedicated users (like the default backup
user in Debian-based distributions).
Right now there are only two possible solutions to accomplish this:
- One might
chown
the repo afterborg create
et al. exits - One might abuse Borg's remote repository feature to connect to
localhost
using SSH as different user (as suggested by @ThomasWaldmann, see references below)
IMO this is a reasonable use case and Borg should support it without taking such rather desperate solutions.
Thus I'd like to suggest adding a socket://
transport (like socket:///run/borg/borg.sock
) to Borg. The socket should be created by borg serve
by accepting an additional --socket
option with a path (e.g. borg serve --socket /run/user/1000/borg/borg.sock
, umask 0117). How borg serve
is being invoked is up to the user. borg create
et al. can now connect to this socket using the socket://
transport (e.g. borg create socket:///run/borg/borg.sock /path/to/backup
).
Even though this is not the goal, it also makes https://github.com/borgbackup/borg/blob/master/docs/deployment/pull-backup.rst#socat easier by eliminating socat
. It might also enable some more use cases I just can't think of right now.
As I don't know Borg's sources I can't really judge the complexity, but since Borg already supports remote transports with borg serve
, this could be as easy as replacing sys.stdin
/sys.stdout
of borg serve
with a UNIX domain socket and to let borg create
et al. communicate with this socket instead of the ssh
subprocess.
References
For non-ssh repos and running borg as root, but not having the repo owned by root, you can use the ssh://user@localhost/myrepo trick.
You can work around that problem by using borg with
user@localhost:/path/to/repo
as repo (in that scenario, borg client can run as root and borg serve would run as user.