This is how you backup your Postgres Database
To Backup
1 | pg_dump --host=localhost --port=5432 --username=postgres --file=YOUR_FILENAME.sql YOUR_DB_NAME |
There are other options such as if you’re interested only on the structure then you can add:
1 | pg_dump --host=localhost --port=5432 --username=postgres --schema-only --format=p --create --inserts --file=YOUR_FILENAME.sql YOUR_DB_NAME |
To Restore
1 | psql -Upostgres -hlocalhost YOUR_DB_NAME < YOUR_FILENAME.sql |