32 lines
1.2 KiB
Bash
Executable File
32 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
. $1 # source the apps.config file with the env vars
|
|
|
|
mkdir -p "emptydir-$ROOT_DOMAIN"
|
|
|
|
# from the restic docs, this allows us to check if the
|
|
# repo is initialized. If it is not, this will have the
|
|
# exit code of 10
|
|
docker run --rm --volume "$PWD/emptydir-$ROOT_DOMAIN:/nassella" --volume $PWD/restic-password:/restic-password -e AWS_ACCESS_KEY_ID="$BACKBLAZE_KEY_ID" -e AWS_SECRET_ACCESS_KEY="$BACKBLAZE_APPLICATION_KEY" -i restic/restic:0.18.0 cat config --repo s3:$BACKBLAZE_BUCKET_URL --password-file /restic-password
|
|
|
|
status=$?
|
|
init_status=0
|
|
|
|
if [ $status -eq 10 ]; then
|
|
# restic repo is not initialized so initialize it
|
|
docker run --rm --volume "$PWD/emptydir-$ROOT_DOMAIN:/nassella" --volume $PWD/restic-password:/restic-password -e AWS_ACCESS_KEY_ID="$BACKBLAZE_KEY_ID" -e AWS_SECRET_ACCESS_KEY="$BACKBLAZE_APPLICATION_KEY" -i restic/restic:0.18.0 init --repo s3:$BACKBLAZE_BUCKET_URL --password-file /restic-password
|
|
init_status=$?
|
|
elif [ $status -ne 0 ]; then
|
|
# something unexpected happened, exit
|
|
rm -Rf "emptydir-$ROOT_DOMAIN"
|
|
exit $status
|
|
fi
|
|
|
|
if [ $init_status -ne 0 ]; then
|
|
# something unexpected happened, exit
|
|
rm -Rf "emptydir-$ROOT_DOMAIN"
|
|
exit $init_status
|
|
fi
|
|
|
|
rm -Rf "emptydir-$ROOT_DOMAIN"
|