Last active
August 20, 2020 13:12
-
-
Save bennylope/81ec4b4eb8d9a8b79055475da6735e4a to your computer and use it in GitHub Desktop.
Create a named database and restore from the lastest downloaded file
This file contains 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
#!/usr/bin/env bash | |
LATEST_DB="$HOME/Downloads/$(ls -t ~/Downloads | head -1)" | |
BACKUP_PATH=${2-$LATEST_DB} | |
DB=$1 | |
echo "Creating database name $DB from $BACKUP_PATH" | |
psql -c "CREATE DATABASE $DB;" | |
echo "Now restoring database $DB from $BACKUP_PATH" | |
pg_restore -O -x -d $DB $BACKUP_PATH #"${@:2}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment