Backup pg_dump
pg_dump name_of_database > name_of_backup_file
Using a remote host
pg_dump -h remote_host -p remote_port name_of_database > name_of_backup_file
To force user with -u option
pg_dump -U user_name -h remote_host -p remote_port name_of_database > name_of_backup_file
Odoo preferred way
pg_dump -F c -f name_of_database.dump name_of_database
Restore psql
psql empty_database < backup_file
Or
psql -U <username> -d <dbname> -1 -f <filename>.sql
To stop backup on every error
psql --set ON_ERROR_STOP=on restored_database < backup_file
Restore pg_restore
pg_restore -U <username> -d <dbname> <filename>.dump
Backup and restore all databases
pg_dumpall > backup_file
psql -f backup_file postgres
Backup exclude table
Add to the command
--exclude-table=table
Backup one table link
Use --table to tell pg_dump what table it has to backup
pg_dump --host localhost --port 5432 --username postgres --format plain --ignore-version --verbose --file "<abstract_file_path>" --table public.tablename dbname