added the ability to change the filename prefix

mike/testing
Christopher Usher 5 years ago
parent 1325ccf280
commit 6b51734bbf

@ -1,6 +1,7 @@
#! /bin/bash #! /bin/bash
NAME=${1:-postgres} PREFIX=${1:-wubloader}
BUCKET=${2:-wubloader-db} NAME=${2:-postgres}
BUCKET=${3:-wubloader-db}
CONTAINER=$(docker ps --format "{{.Names}}" | grep "$NAME") CONTAINER=$(docker ps --format "{{.Names}}" | grep "$NAME")
if [ -z "$CONTAINER" ]; then if [ -z "$CONTAINER" ]; then
echo "Container not found" echo "Container not found"
@ -11,6 +12,6 @@ if [ "$(wc -l <<<"$CONTAINER")" -ne 1 ]; then
exit 1 exit 1
fi fi
FILE="wubloader-$(date +%Y-%m-%dT%H:%M:%S).sql" FILE="$PREFIX-$(date +%Y-%m-%dT%H:%M:%S).sql"
echo "Dumping $CONTAINER to $FILE" echo "Dumping $CONTAINER to $FILE"
docker exec $CONTAINER pg_dump wubloader -U postgres | aws s3 cp - "s3://$BUCKET/$FILE" docker exec $CONTAINER pg_dump wubloader -U postgres | aws s3 cp - "s3://$BUCKET/$FILE"

Loading…
Cancel
Save