New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add non-root deployment strategy #8114
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations on your first PR. Have your first review, too! :p
Co-authored-by: NetSysFire <59517351+NetSysFire@users.noreply.github.com>
Looks pretty good! How would one extract system files from such a repo, preferably without messing up repo permissions? |
Ah yes, good question. I mount the repo as root and not the non-root user, when restoring files, since as you say yourself, you would not be able to open system files otherwise. That should probably also be included in the description. Let me get right on that. |
Can you check the files in the repo after doing that: is anything then owned by root rather than the non-root user? |
Using borg extract or borg mount and then a tool like rsync -a both work and keep the correct permissions.
Both times the files a correctly owned by the user acme and not by root. I think, the repo itself should not be able to know if root or a non-root user with the CAP_DAC_READ_SEARCH capability created the backup. Anything else I should consider / test / add to the document? |
In case of using a remote repo with an explicit user given (like ssh://borg@backupserver/...) there is no problem, because it will always be that user that accesses the repo. With a local repo, it will use the current user, so that will vary between root and non-root in this case, which might lead to a mixup of file owners in the repo. |
There is the trick to use ssh://borg@localhost/... one could use for the local case to avoid such issues. |
I just tested that. I wasn't even aware local repos without ssh are a thing :-) I created a repo with a non-root user. Run an initial backup and then used root to restore the same srv directory as before. I would say to be sure I will add a warning block in the docs that when using the root user and a local repo, care has to be taken not to use any functions that modify the repository but restore and mount are fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@stephan13360 could you forward port this to master branch? if you like, it could be also backported to 1.2-maint branch, but this is rather of short term interest, because soon 1.4.x will supersede 1.2.x. |
Add a deployment strategy describing how to run borg as a non-root user and still be able to access/backup all files on the system.
I was not sure if I should include more about how/where to create the systemd service and timer files. I feel like this would not be the place to explain basic systemd, so I kept it short. If someone feels different, I could add more detail.