Skip to content

Instantly share code, notes, and snippets.

@treyhuffine
Created January 21, 2020 23:50
Show Gist options
  • Save treyhuffine/17760f99b025fec29bf9f1d86aa656d4 to your computer and use it in GitHub Desktop.
Save treyhuffine/17760f99b025fec29bf9f1d86aa656d4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
echo "Restoring database"
psql -U postgres -c "CREATE DATABASE ${DBNAME}"
pg_restore -v -d ${DBNAME} /tmp/${FILE} > /tmp/log
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE ${DBNAME} TO postgres"
echo "Database restored successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment