Question
How do I restore a copy of my Postgres database?
Answer
To restore the databases as user Postgres, first, move your archive into /var/lib/pgsql
and change its owner/group to user Postgres, then create the database via cPanel along with users and user assignments.
You will also need the root PostGreSQL password found in /root/.pgpass
.
su -l postgres
cd /var/lib/pgsql
pg_restore -v -C -O -d databasename -v databasename.tar
Alternatively, if it is already extracted, you can use the following commands instead:
su -l postgres
psql -d database -f /path/to/db.out