This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
2021-01-19 16:58:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-01-20 14:27:12 +00:00
|
|
|
# Get current working directory (pwd doesn't cut it)
|
|
|
|
cwd=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
2021-01-20 13:46:48 +00:00
|
|
|
# Set the environment:
|
|
|
|
set -o allexport
|
2021-01-20 14:27:12 +00:00
|
|
|
source $cwd/../.env
|
2021-01-20 13:46:48 +00:00
|
|
|
set +o allexport
|
2021-01-20 14:27:12 +00:00
|
|
|
# Check for AWS credentials:
|
|
|
|
if [[ $AWS_ACCESS_KEY_ID == "" || $AWS_SECRET_ACCESS_KEY == "" ]]; then
|
|
|
|
echo "Missing AWS credentials!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-01-19 16:58:08 +00:00
|
|
|
# Take the current datetime:
|
|
|
|
DT=`date +%Y-%m-%d`
|
|
|
|
# Create the backup:
|
|
|
|
docker exec cockroach \
|
|
|
|
cockroach sql \
|
|
|
|
--host cockroach:26257 \
|
|
|
|
--certs-dir=/certs \
|
2021-01-20 13:46:48 +00:00
|
|
|
--execute="BACKUP TO 's3://skynet-crdb-backups/backups/$DT?AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID&AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY';"
|