pg_dump and restore on MacOS

Using brew, install the postgres package:

brew install postgresql@14

Then restart your terminal, and you can use the commands as usual.


pg_dump:

pg_dump -U postgres -h 127.0.0.1 -p 5432 my_db_name > backup.sql

restore:

psql -U postgres -h 127.0.0.1 -p 5432 my_db_name -1 -f  ./backup.sql