This is how you backup your Postgres Database
To Backup
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:
pg_dump --host=localhost --port=5432 --username=postgres --schema-only --format=p --create --inserts --file=YOUR_FILENAME.sql YOUR_DB_NAME
To Restore
psql -Upostgres -hlocalhost YOUR_DB_NAME < YOUR_FILENAME.sql