borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
11k stars 741 forks source link

run in venv w/ root rights #8202

Closed CrysK closed 4 months ago

CrysK commented 4 months ago

Hello folks,

I have switched borg from apt v1.2.0 to python3 v1.2.8 (Ubuntu 22 LTS). So far everything has worked great, everything according to the instructions. I have installed everything in a user virtualenv. But now I don't have access to my old backups anymore, because I had run them in the past as root (I think because I also backed up /boot /etc ...). But I can't start borg as root in venv: ERROR: unknown command "borg"

What do I change so that I can run borg with the existing backups? Do I have to change the rights of the backups? Or do I have to install borg as root in a venv (which is not the purpose of a venv!?)?

Thank you very much!

RonnyPfannschmidt commented 4 months ago

as you didn't share the command you executed I suspect you tried to use sudo to run borg in the venv, and sudo rightfully took the venv out of the path

if you use sudo on a borg installed in a virtualenv, you need to pass the complete path of the executable

CrysK commented 4 months ago

as you didn't share the command you executed

I try as user:

source borg1-env/bin/activate
sudo borg info /path/to/repo

and get sudo: borg: command not found

the same with:

alias borg='source borg1-env/bin/activate; borg'
borg info /path/to/repo
# or
sudo borg info /path/to/repo

as root on the complicated way:

sudo su
cd /
source borg1-su-env/bin/activate # this is a another venv
borg info /path/to/repo # this works

Is there a possibility that I "simply" use borg. Freshly rolled into the console simplyborg or sudo borg?

CrysK commented 4 months ago

The simplest option is often the best: just use the binaries: https://borgbackup.readthedocs.io/en/stable/installation.html#standalone-binary