TO make a database backup in postgreslq server you use pg_dump and psql commands.
First, locate the database:
# psql -l --username postgres --password
Then:
# pg_dump --username postgres name_db --file /dir/dir/backup.sql
To restore the database:
First create database with its respective name and roles:
# psql postgres # postgres=# CREATE DATABASE name_db ENCODING 'UTF-8'; # postgres=# CREATE ROLE root LOGIN;
Restoring:
# psql name_db < /dir/dir/backup.sql
That’s all.