You didn't mention how your backup was made, so the generic answer is: Usually with the psql
tool.
Depending on what pg_dump
was instructed to dump, the SQL file can have different sets of SQL commands.
For example, if you instruct pg_dump
to dump a database using --clean
and --schema-only
, you can't expect to be able to restore the database from that dump as there will be no SQL commands for COPYing (or INSERTing if --inserts
is used ) the actual data in the tables. A dump like that will contain only DDL SQL commands, and will be able to recreate the schema but not the actual data.
A typical SQL dump is restored with psql
:
psql (connection options here) database < yourbackup.sql
or alternatively from a psql
session,
psql (connection options here) database
database=# i /path/to/yourbackup.sql
In the case of backups made with pg_dump -Fc
("custom format"), which is not a plain SQL file but a compressed file, you need to use the pg_restore
tool.
If you're working on a unix-like, try this:
man psql
man pg_dump
man pg_restore
otherwise, take a look at the html docs. Good luck!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…