Skip to content
Snippets Groups Projects
Commit 4b809ff8 authored by Michael Hollister's avatar Michael Hollister
Browse files

Revert "Merge branch 'michael/multiple-database-restore' into 'master'"

This reverts commit be87fe1d, reversing
changes made to 9beb7d7a.
parent be87fe1d
Branches master
No related tags found
No related merge requests found
......@@ -13,39 +13,32 @@ else
file_type=".dump.gpg"
fi
OIFS="$IFS"
IFS=','
for DB in $POSTGRES_DATABASE
do
IFS="$OIFS"
if [ $# -eq 1 ]; then
timestamp="$1"
key_suffix="${DB}_${timestamp}${file_type}"
else
echo "Finding latest backup..."
key_suffix=$(
aws $aws_args s3 ls "${s3_uri_base}/${DB}" \
| sort \
| tail -n 1 \
| awk '{ print $4 }'
)
fi
echo "Fetching backup from S3..."
aws $aws_args s3 cp "${s3_uri_base}/${key_suffix}" "db${file_type}"
if [ -n "$PASSPHRASE" ]; then
echo "Decrypting backup..."
gpg --decrypt --batch --passphrase "$PASSPHRASE" db.dump.gpg > db.dump
rm db.dump.gpg
fi
conn_opts="-h $POSTGRES_HOST -p $POSTGRES_PORT -U $POSTGRES_USER -d $DB"
echo "Restoring from backup..."
pg_restore $conn_opts --clean --if-exists db.dump
rm db.dump
done
if [ $# -eq 1 ]; then
timestamp="$1"
key_suffix="${POSTGRES_DATABASE}_${timestamp}${file_type}"
else
echo "Finding latest backup..."
key_suffix=$(
aws $aws_args s3 ls "${s3_uri_base}/${POSTGRES_DATABASE}" \
| sort \
| tail -n 1 \
| awk '{ print $4 }'
)
fi
echo "Fetching backup from S3..."
aws $aws_args s3 cp "${s3_uri_base}/${key_suffix}" "db${file_type}"
if [ -n "$PASSPHRASE" ]; then
echo "Decrypting backup..."
gpg --decrypt --batch --passphrase "$PASSPHRASE" db.dump.gpg > db.dump
rm db.dump.gpg
fi
conn_opts="-h $POSTGRES_HOST -p $POSTGRES_PORT -U $POSTGRES_USER -d $POSTGRES_DATABASE"
echo "Restoring from backup..."
pg_restore $conn_opts --clean --if-exists db.dump
rm db.dump
echo "Restore complete."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment