I've been trying to setup a borg automated backup script following the documentation. For some reason my script fails to see its variables while I'm trying to write to a sudo protected encrypted drive.
For example, something like this works as the script as the script doesn't ask me a password again.
#!/bin/sh
DATE=$(date --iso-8601)-$(hostname)
TARGET=~/Documents/borg
export BORG_PASSPHRASE="whatever"
borg init --encryption=repokey $TARGET
borg create $TARGET::$DATE-$$ ~/Desktop/TestFolder/1
However when I mount an external FDE implemented drive, it ignores the exported password and and weirdly enough the "repokey" encryption mode.
#!/bin/sh
DATE=$(date --iso-8601)-$(hostname)
TARGET=~/X/borg
export BORG_PASSPHRASE="whatever"
sudo borg init --encryption=repokey $TARGET
sudo borg create $BORG_OPTS $TARGET::$DATE-$$ ~/Desktop/TestFolder/1
I'm fairly new to Linux so this is probably an easy fix but I couldn't do it on my own when I referred to other answers. Please help.
sudo, and it can well filter away environment variables. Try e.g.export BORG_PASSPHRASE=test; sudo sh -c 'echo $BORG_PASSPHRASE'to see if it prints anything. Also I can't see you setBORG_OPTSanywhere, even though the second script uses it