From 81b0b06462c3b30b08966866d3a844979a0ab3a4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 26 Nov 2006 18:11:11 +0000 Subject: [PATCH] Make pg_restore usage examples more useful: illustrate restoring into both the same database name and a different one. --- doc/src/sgml/ref/pg_restore.sgml | 40 ++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index edbbba808f..e7c4ee036e 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -1,4 +1,4 @@ - + @@ -580,34 +580,54 @@ CREATE DATABASE foo WITH TEMPLATE template0; Examples - To dump a database called mydb to a tar - file: + Assume we have dumped a database called mydb into a + custom-format dump file: -$ pg_dump -Ft mydb > db.tar +$ pg_dump -Fc mydb > db.dump - To reload this dump into an - existing database called newdb: + To drop the database and recreate it from the dump: -$ pg_restore -d newdb db.tar +$ dropdb mydb +$ pg_restore -C -d postgres db.dump + + The database named in the + + + To reload the dump into a new database called newdb: + + +$ createdb -T template0 newdb +$ pg_restore -d newdb db.dump + + + Notice we don't use To reorder database items, it is first necessary to dump the table of contents of the archive: -$ pg_restore -l archive.file > archive.list +$ pg_restore -l db.dump > db.list The listing file consists of a header and one line for each item, e.g., ; ; Archive created at Fri Jul 28 22:28:36 2000 -; dbname: birds +; dbname: mydb ; TOC Entries: 74 ; Compression: 0 ; Dump Version: 1.4-0 @@ -645,7 +665,7 @@ CREATE DATABASE foo WITH TEMPLATE template0; could be used as input to pg_restore and would only restore items 10 and 6, in that order: -$ pg_restore -L archive.list archive.file +$ pg_restore -L db.list db.dump