Skip to content

Commit

Permalink
1550 s3 dmp tagging (#1565)
Browse files Browse the repository at this point in the history
* add tag for s3 lifecycle policy

* update --key value

* tag both TODAY and latest dmp files for lifecycle policy
  • Loading branch information
jkueloc committed Nov 8, 2021
1 parent 094a81c commit 40d4c66
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions db_scripts/dump/dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ if [ $ENV_NAME != "prod" ]; then
fi

TODAY=$(date +%Y%m%d)
if [[ "$TODAY" =~ (0101|0401|0701|1001)$ ]]; then
TAGVALUE="true"
else
TAGVALUE="false"
fi
POSTGRESQL_PW="$(aws secretsmanager get-secret-value --region us-east-1 --secret-id crowd/${ENV_NAME}/DB/MasterUserPassword | python -c 'import json,sys;Secret=json.load(sys.stdin);SecretString=json.loads(Secret["SecretString"]);print(SecretString["password"])')"
POSTGRESQL_HOST="$(aws ssm get-parameter --region us-east-1 --name /concordia/${ENV_NAME}/db.url | python -c 'import json,sys;ParameterInput=json.load(sys.stdin);Parameter=ParameterInput["Parameter"];print(Parameter["Value"])')"
DUMP_FILE=concordia.dmp
Expand All @@ -28,5 +33,7 @@ pg_dump -Fc --no-acl -U concordia -h "${POSTGRESQL_HOST}" concordia -f "${DUMP_F
if [ -s $DUMP_FILE ]; then
aws s3 cp "${DUMP_FILE}" "s3://crowd-deployment/database-dumps/concordia.${TODAY}.dmp"
aws s3 cp "${DUMP_FILE}" s3://crowd-deployment/database-dumps/concordia.latest.dmp
aws s3api put-object-tagging --bucket 'crowd-deployment' --key database-dumps/concordia.${TODAY}.dmp --tagging '{"TagSet": [{ "Key": "first-dmp-of-quarter", "Value": "'${TAGVALUE}'" }]}'
aws s3api put-object-tagging --bucket 'crowd-deployment' --key database-dumps/concordia.latest.dmp --tagging '{"TagSet": [{ "Key": "first-dmp-of-quarter", "Value": "'${TAGVALUE}'" }]}'
fi
echo $?

0 comments on commit 40d4c66

Please sign in to comment.