Created
March 21, 2019 09:28
-
-
Save quangthe/8fe0d3e5d4ceefd47cccb540f862e20e to your computer and use it in GitHub Desktop.
Restore tienluong db from dump/snapshot file (stored in S3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Run this script to prepare DB for "prod" profile. | |
# Require environment variable: | |
# AWS_ACCESS_KEY_ID | |
# AWS_SECRET_ACCESS_KEY | |
set -e | |
BUCKET=dtcorpbackup | |
echo "Get latest backup" | |
OBJECT="$(aws s3 ls $BUCKET --recursive | sort | tail -n 1 | awk '{print $4}')" | |
aws s3 cp s3://$BUCKET/$OBJECT $OBJECT | |
echo "Restore DB to latest backup" | |
cat $OBJECT | docker exec -i tienluong-db psql -U postgres | |
rm $OBJECT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment