Skip to content

Commit

Permalink
Merge branch '2019-season-db'
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeTheCanuck committed May 19, 2019
2 parents 045b268 + 2f23fcc commit eadf1d2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/create-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ if [ "$#" -eq 3 ]; then
sudo -u postgres createuser --encrypted --no-createdb --no-createrole --no-superuser --no-replication $USERNAME
sudo -u postgres psql -c ${SET_PWD_COMMAND}
elif [ "$#" -eq 0 ]; then
# Running interatively (no arguments)
# Running interactively (no arguments)
echo "Enter the name of the database and username of that database's owner"
echo 'NOTE: the database naming convention is (without bracket): <the project name>-<data purpose>'
read -p "Database name: " DB_NAME
read -p "Username: " USERNAME
Expand Down
3 changes: 2 additions & 1 deletion bin/upload-and-ssh-into-ec2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
EC2MACHINE=$1 # Public DNS of the EC2 VM e.g. ec2-54-200-42-122.us-west-2.compute.amazonaws.com
FILETOUPLOAD="*"
# PEMFILE=$2
PEMFILE="~/.ssh/hackoregon-2018-database-dev-env.pem"
# PEMFILE="~/.ssh/hackoregon-2018-database-dev-env.pem"
PEMFILE="~/.ssh/hackoregon-integration-ecs.pem"

scp -i $PEMFILE $FILETOUPLOAD ec2-user@${EC2MACHINE}:~
ssh -i $PEMFILE ec2-user@${EC2MACHINE}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# HOWTO: use the "DB jumpbox" to restore PostgreSQL database from S3

Summary: SSH into the jumpbox, grab your backup file, restore your backup.

## Steps

1. *Get the keys*: Talk to #team-infra on our Slack group to get a copy of the SSH keys (in `.pem` format)
2. *Place the keys*: Download the .pem file then run `mv hackoregon-2019-db-restore-jumpbox.pem ~/.ssh`
3. *Secure the keys*: Run `chmod 400 ~/.ssh/hackoregon-2019-db-restore-jumpbox.pem`
4. *Use the keys to get into the box*: Run `ssh -i ~/.ssh/hackoregon-2019-db-restore-jumpbox.pem ec2-user@ec2-34-220-186-62.us-west-2.compute.amazonaws.com` to get into the jumpbox
5. *Get the backup file*: Copy your backup from the S3 location with a command of the form aws s3 cp s3://hacko-data-archive/(team folder)/(backups folder)/(backup file name) /backups
e.g. s3://hacko-data-archive/2017-team-budget/database-backup/budget.sql.gz /backups
6. *Restore your backup*: Run whatever command(s) you need to restore your database/data to your team's RDS instance for your team
7. *Cleanup your backup*: rm -rf /backups/*.*

Your restore procedure will vary depending on the backup tools you're using, the kind of backup (e.g. data, schema or to-be-converted CSV) and where it's headed.
File renamed without changes.

0 comments on commit eadf1d2

Please sign in to comment.