Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
81b0b064
Commit
81b0b064
authored
Nov 26, 2006
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make pg_restore usage examples more useful: illustrate restoring into
both the same database name and a different one.
parent
50271fc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
10 deletions
+30
-10
doc/src/sgml/ref/pg_restore.sgml
doc/src/sgml/ref/pg_restore.sgml
+30
-10
No files found.
doc/src/sgml/ref/pg_restore.sgml
View file @
81b0b064
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.6
3 2006/10/14 23:07:22
tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.6
4 2006/11/26 18:11:11
tgl Exp $ -->
<refentry id="APP-PGRESTORE">
<refmeta>
...
...
@@ -580,34 +580,54 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<title>Examples</title>
<para>
To dump a database called <literal>mydb</> to a <filename>tar</filename>
file:
Assume we have dumped a database called <literal>mydb</> into a
custom-format dump
file:
<screen>
<prompt>$</prompt> <userinput>pg_dump -F
t mydb > db.tar
</userinput>
<prompt>$</prompt> <userinput>pg_dump -F
c mydb > db.dump
</userinput>
</screen>
</para>
<para>
To reload this dump into an
existing database called <literal>newdb</>:
To drop the database and recreate it from the dump:
<screen>
<prompt>$</prompt> <userinput>pg_restore -d newdb db.tar</userinput>
<prompt>$</prompt> <userinput>dropdb mydb</userinput>
<prompt>$</prompt> <userinput>pg_restore -C -d postgres db.dump</userinput>
</screen>
The database named in the <option>-d</> switch can be any database existing
in the cluster; <application>pg_restore</> only uses it to issue the
<command>CREATE DATABASE</> command for <literal>mydb</>. With
<option>-C</>, data is always restored into the database name that appears
in the dump file.
</para>
<para>
To reload the dump into a new database called <literal>newdb</>:
<screen>
<prompt>$</prompt> <userinput>createdb -T template0 newdb</userinput>
<prompt>$</prompt> <userinput>pg_restore -d newdb db.dump</userinput>
</screen>
Notice we don't use <option>-C</>, and instead connect directly to the
database to be restored into. Also note that we clone the new database
from <literal>template0</> not <literal>template1</>, to ensure it is
initially empty.
</para>
<para>
To reorder database items, it is first necessary to dump the table of
contents of the archive:
<screen>
<prompt>$</prompt> <userinput>pg_restore -l
archive.file > archive
.list</userinput>
<prompt>$</prompt> <userinput>pg_restore -l
db.dump > db
.list</userinput>
</screen>
The listing file consists of a header and one line for each item, e.g.,
<programlisting>
;
; 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 <application>pg_restore</application> and would only restore
items 10 and 6, in that order:
<screen>
<prompt>$</prompt> <userinput>pg_restore -L
archive.list archive.file
</userinput>
<prompt>$</prompt> <userinput>pg_restore -L
db.list db.dump
</userinput>
</screen>
</para>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment