Created
December 3, 2014 22:10
-
-
Save feltnerm/0f30dd208f83d8f5c536 to your computer and use it in GitHub Desktop.
Grab a SQL dump from S3
This file contains hidden or 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
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