Skip to content

Instantly share code, notes, and snippets.

@feltnerm
Created December 3, 2014 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feltnerm/0f30dd208f83d8f5c536 to your computer and use it in GitHub Desktop.
Save feltnerm/0f30dd208f83d8f5c536 to your computer and use it in GitHub Desktop.
Grab a SQL dump from S3
DEFAULT_BUCKET="s3://FOO_DATABASEt"
## Grab an SQL dump from S3
#
# String client_name Corresponds to the db name in S3
#
function download_dump() {
local client_name=$1
local date=$(aws s3 ls $DEFAULT_BUCKET | tail -n 1 | sed -e 's/^ *//' -e 's/ *$//' | cut -d' ' -f2)
local date="${date%/}"
local key=$DEFAULT_BUCKET/$date/$client_name.sql.zip
echo $(aws s3 cp $key . 2>&1 >/dev/null && unzip $client_name.sql.zip && rm -rf $client_name.sql.zip)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment