Wednesday, 13 June 2018

How to restore a backup made plain format


PGAdminIII can make backups in three formats:

1. Plain
2. Custom
3, Tar

Custom and Tar backups can be restored with PGAdminIII or pg_restore. Plain backups must be restored with psql.

Option 1:

1. Open psql and log into the database postgres
2. Type CREATE DATABASE databasename;



3. Log into the database by typing \c databasename. (in this example \c test)


4. Type \i path/to/backupfile (in this example \i c:/pgbackup/testplain.backup)


5. The backup will now be restored

Option 2

1. Go to the command prompt (Windows) or the console (Linux) and make sure that the user is the postgres user
2. On Windows: Press Shift and Right Click on the Command Prompt icon and select Run as different user
3. On Linux: Type su postgres to change the user to the postgres user
4. Go to the bin directory (it is a sub directory under PostgreSQL/10)
5. Type createdb databasename (in this example createdb test). This will create the database


6. Type psql databasename < path/to/backupfile (in this example psql test < c:/pgbackup/testplain.backup)


7. The backup will now be restored







No comments:

Post a Comment