Ensuring restic is initialized.
This commit is contained in:
2
Makefile
2
Makefile
@@ -125,7 +125,7 @@ plan: ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
|||||||
announce-start:
|
announce-start:
|
||||||
echo "NASSELLA_CONFIG: start"
|
echo "NASSELLA_CONFIG: start"
|
||||||
|
|
||||||
apply: announce-start ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
apply: announce-start restic-init ignition.json $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars
|
||||||
echo "NASSELLA_CONFIG: end"
|
echo "NASSELLA_CONFIG: end"
|
||||||
terraform init
|
terraform init
|
||||||
bash -c "terraform apply -auto-approve -input=false -var-file=<(cat $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars)"
|
bash -c "terraform apply -auto-approve -input=false -var-file=<(cat $(config_dir)$(TERRAFORM_ENV).tfvars generated.tfvars)"
|
||||||
|
|||||||
@@ -1,9 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
. $1 # source the apps.config file with the env vars
|
||||||
|
|
||||||
. $1 # source the apps.config file with then env vars
|
mkdir -p "emptydir-$ROOT_DOMAIN"
|
||||||
|
|
||||||
mkdir -p emptydir
|
# from the restic docs, this allows us to check if the
|
||||||
docker run --rm --volume $PWD/emptydir:/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
|
# repo is initialized. If it is not, this will have the
|
||||||
rm -Rf emptydir
|
# 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"
|
||||||
|
|||||||
Reference in New Issue
Block a user