chown after download of borg repo

This commit is contained in:
Christoph J. Scherr 2023-06-11 18:48:16 +02:00
parent 5949231340
commit 998538bb12
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 5 additions and 3 deletions

View File

@ -4,20 +4,22 @@ if [[ -z "${BORG_PASSPHRASE}" ]]; then
echo 'BORG_PASSPHRASE is not set, cannot continue' echo 'BORG_PASSPHRASE is not set, cannot continue'
exit exit
fi fi
cd /srv/data/backup/borg/snowboard REPO_ROOT=/srv/data/backup/borg/snowboard
SCRIPTS_DIR=/usr/local/cron/scripts
cd $REPO_ROOT
mkdir -p old mkdir -p old
mv data* old mv data* old
backupdir="data-$(date -I)" backupdir="data-$(date -I)"
mkdir -p $backupdir mkdir -p $backupdir
cd $backupdir cd $backupdir
sftp fileserver@cscherr.de < /usr/local/cron/scripts/sftp-commands.txt sftp fileserver@cscherr.de < $SCRIPTS_DIR/sftp-commands.txt
status_download=$? status_download=$?
echo "finished downloading from snowboard. Status: $status_download" echo "finished downloading from snowboard. Status: $status_download"
borg check -v data/backup/borg/snowboard borg check -v data/backup/borg/snowboard
status_check=$? status_check=$?
echo "finished checking the downloaded repo. Status: $status_check" echo "finished checking the downloaded repo. Status: $status_check"
if [ "$status_check" -eq "0" ]; then if [ "$status_check" -eq "0" ]; then
cd /srv/data/backup/borg/snowboard chown fileserver:fileserver $REPO_DIR/$backupdir
rm -r old rm -r old
else else
echo "the new repo was not checked successfully, keeping old repo." echo "the new repo was not checked successfully, keeping old repo."