Category Archives: Databases

Simple Backup / Restore DataBase in postgresql

TO make a database backup in postgreslq server you use pg_dump and psql commands.

First, locate the database:

# psql -l --username postgres --password


# 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;


# psql name_db < /dir/dir/backup.sql

That’s all.