Skip to content

Instantly share code, notes, and snippets.

@ImLoaD
Created August 3, 2021 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImLoaD/ae4479b591af47aeb9fa028b0c854064 to your computer and use it in GitHub Desktop.
Save ImLoaD/ae4479b591af47aeb9fa028b0c854064 to your computer and use it in GitHub Desktop.
Export database schema from PostgreSQL
#!/bin/sh
DEFAULT_DB_NAME="my_web_admin"
read -p "Enter the database name to make schema dump [$DEFAULT_DB_NAME]" DB_NAME
DB_NAME=${name:-$DEFAULT_DB_NAME}
FILE_NAME=${DB_NAME}_schema.sql
echo "I will create a file called $FILE_NAME"
pg_dump -h localhost -U postgres -s $DB_NAME > "$FILE_NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment