Sunday, 5 July 2015

Steps for postgres db backup and restore through command line

================================================================

Steps for postgres db backup and restore through command line
-------------------------------------------------------------

To take pg backup
~~~~~~~~~~~~~~~

# su - postgres
$ /opt/PostgreSQL/9.4/bin/pg_dump cawc > /opt/PostgreSQL/9.4/data/cawc_bck.sql


To restore pg backup
~~~~~~~~~~~~~~~~~
**For remote system
**Copy the created backup file ( cawc_bck.sql ) in /opt/PostgreSQL/9.4/data/ directory ( to avoid db user permission )

#su - postgres
$ /opt/PostgreSQL/9.4/bin/psql -d cawc -f /opt/PostgreSQL/9.4/data/cawc_bck.sql

No comments:

Post a Comment