From 83b0be5ae5abecd2076cab8b7ab2a84e9756034a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 28 May 2019 00:46:24 -0300 Subject: Add backup routing before possibly tearing down machine Create a new backup entry before running =terraform apply=, which may (or may not) destroy the current machine. This shouldn't be an issue for the backup itself, since all of the data should be stored in a separate Block Storage Volume, but we can take advantage of the sevices already needing to be taken down in order to perform a full backup of the data. --- provision.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'provision.sh') diff --git a/provision.sh b/provision.sh index 42e7990..e5f6baf 100755 --- a/provision.sh +++ b/provision.sh @@ -5,8 +5,11 @@ set -Eeuo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" echo "Shutting down running containers and backing up data..." -envsubst < backup-and-shutdown.sh | ssh "$TLD" 'cat > /home/vps/backup-and-shutdown.sh' -ssh "$TLD" /home/vps/backup-and-shutdown.sh +ssh "$TLD" "cd /home/vps/ && docker-compose down" +scp ./secrets/borg_remote.pub "$TLD":/root/.ssh/id_rsa.pub +scp ./secrets/borg_remote "$TLD":/root/.ssh/id_rsa +envsubst < run-backup-template.sh | ssh "$TLD" 'cat > /home/vps/run-backup.sh && chmod +x /home/vps/run-backup.sh' +ssh "$TLD" /home/vps/run-backup.sh echo "Done." echo "Running 'terraform apply'..." -- cgit v1.3