Can't export variables within script
1
vote
1
answer
162
views
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.
Asked by Nate4545
(13 rep)
Sep 7, 2021, 08:10 PM
Last activity: Sep 7, 2021, 10:11 PM
Last activity: Sep 7, 2021, 10:11 PM