-
-
Save rnschmidt/567cdd98fa5e577e4c99bfcd8dc2ef1c 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