From a05555f93e2252bfbf34889a46bbb0259b68adeb Mon Sep 17 00:00:00 2001 From: Ivaylo Novakov Date: Wed, 20 Jan 2021 13:17:24 +0100 Subject: [PATCH] Backup to S3. --- scripts/crdb_backup.sh | 2 +- scripts/crdb_restore.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 scripts/crdb_restore.sh diff --git a/scripts/crdb_backup.sh b/scripts/crdb_backup.sh index 8679aa34..9e928160 100644 --- a/scripts/crdb_backup.sh +++ b/scripts/crdb_backup.sh @@ -7,4 +7,4 @@ docker exec cockroach \ cockroach sql \ --host cockroach:26257 \ --certs-dir=/certs \ - --execute="BACKUP TO 'http://cockroach-backup:3000/cockroach/backups/$DT';" + --execute="BACKUP TO 's3://skynet-crdb-backups/backups/$DT?AWS_ACCESS_KEY_ID=$AWS_KEY_ID&AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KET';" diff --git a/scripts/crdb_restore.sh b/scripts/crdb_restore.sh new file mode 100644 index 00000000..b78b0061 --- /dev/null +++ b/scripts/crdb_restore.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +BACKUP=$1 +if [[ $BACKUP == "" ]]; then + echo "No backup name given. It should look like '2020-01-29'." + exit 1 +fi + +docker exec cockroach \ + cockroach sql \ + --host cockroach:26257 \ + --certs-dir=/certs \ + --execute="RESTORE DATABASE defaultdb FROM 's3://skynet-crdb-backups/backups/$DT?AWS_ACCESS_KEY_ID=$AWS_KEY_ID&AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KET';"