PostgreSQL method

  1. Navigate to your database bin folder, by default this is at C:\Testdriver\db\bin
  2. Open a command prompt to this location
  3. Enter the following command, replacing the path after --file with your desired output file name:


Testdriver 1.6:

C:\Testdriver\db\bin\pg_dump -h localhost -U postgres --format=c --file=<filename.sqlc> testdriver


Testdriver 2.0:

C:\Testdriver\db16.3\bin\pg_dump -h localhost -U postgres --format=c --file=<filename.sqlc> testdriver


Execute this command inside the folder where you want the backup to be, or modifying the --file section by adding the full path to the target file. Substitute <filename.sqlc> with the desired file name.


Restore a database from a dump file

  1. Navigate to your database bin folder, by default this is at C:\Testdriver\db\bin
  2. Open a command prompt to this location
  3. Create the Testdriver user, enter the following command : createuser.exe  --username=postgres testdriver
  4. Create the Testdriver database, enter the following command : createdb.exe --username=testdriver testdriver
  5. Finally to restore the data from the database dump, enter the following command, replacing the path after --file with your desired output file name : 


Testdriver 1.6:

C:\Testdriver\db\bin\pg_restore.exe -h localhost -U postgres -d testdriver <filename.sqlc>


Testdriver 2.0:

C:\Testdriver\db16.3\bin\pg_restore.exe -h localhost -U postgres -d testdriver <filename.sqlc>


Execute this command in the folder where the database dump is located at, or add a full path to the target file. Substitute <filename.sqlc> with the desired file name.


Other methods


There are many other backup options for PostgreSQL available, more details on the above method can be found here: 

https://www.postgresql.org/docs/9.4/static/backup-dump.html

High-end solutions are also possible, the documentation explaining the different methods and implementations can be found on the PostgreSQL website:

http://www.postgresql.org/docs/9.1/static/high-availability.html