~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/bin/pg_dump/README

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Notes on pg_dump
 
2
================
 
3
 
 
4
1. pg_dump, by default, still outputs text files.
 
5
 
 
6
2. pg_dumpall forces all pg_dump output to be text, since it also outputs text into the same output stream.
 
7
 
 
8
3. The plain text output format can not be used as input into pg_restore.
 
9
 
 
10
4. pg_dump now dumps the items in a modified OID order to try to improve relaibility of default restores.
 
11
 
 
12
 
 
13
To dump a database into the next custom format, type:
 
14
 
 
15
    pg_dump <db-name> -Fc > <backup-file>
 
16
 
 
17
or, in TAR format
 
18
 
 
19
        pg_dump <db-name> -Ft > <backup-file>
 
20
 
 
21
To restore, try
 
22
 
 
23
   To list contents:
 
24
 
 
25
       pg_restore -l <backup-file> | less
 
26
 
 
27
   or to list tables:
 
28
 
 
29
       pg_restore <backup-file> --table | less
 
30
 
 
31
   or to list in a differnet orderL
 
32
 
 
33
       pg_restore <backup-file> -l --oid --rearrange | less
 
34
 
 
35
Once you are happy with the list, just remove the '-l', and an SQL script will be output.
 
36
 
 
37
 
 
38
You can also dump a listing:
 
39
 
 
40
       pg_restore -l <backup-file> > toc.lis
 
41
  or
 
42
       pg_restore -l <backup-file> -f toc.lis
 
43
 
 
44
edit it, and rearrange the lines (or delete some):
 
45
 
 
46
    vi toc.lis
 
47
 
 
48
then use it to restore selected items:
 
49
 
 
50
    pg_restore <backup-file> --use=toc.lis -l | less
 
51
 
 
52
When you like the list, type
 
53
 
 
54
    pg_restore backup.bck --use=toc.lis > script.sql
 
55
 
 
56
or, simply:
 
57
 
 
58
    createdb newdbname
 
59
    pg_restore backup.bck --use=toc.lis | psql newdbname
 
60
 
 
61
 
 
62
BLOBs
 
63
=====
 
64
 
 
65
To dump blobs you must use the custom archive format (-Fc) or TAR format (-Ft), and specify the 
 
66
--blobs qualifier to the pg_dump command.
 
67
 
 
68
To restore blobs you must use a direct database connection (--db=db-to-restore-to).
 
69
 
 
70
eg.
 
71
 
 
72
   pg_dump --blob -Fc db-to-backup -f backup.bck
 
73
 
 
74
   pg_restore backup.bck --db=db-to-restore-into
 
75
 
 
76
 
 
77
TAR
 
78
===
 
79
 
 
80
The TAR archive that pg_dump creates currently has a blank username & group for the files, 
 
81
but should be otherwise valid. It also includes a 'restore.sql' script which is there for
 
82
the benefit of humans. It is never used by pg_restore.
 
83
 
 
84
Note: the TAR format archive can only be used as input into pg_restore if it is in TAR form.
 
85
(ie. you should not extract the files then expect pg_restore to work). 
 
86
 
 
87
You can extract, edit, and tar the files again, and it should work, but the 'toc'
 
88
file should go at the start, the data files be in the order they are used, and
 
89
the BLOB files at the end.
 
90
 
 
91
 
 
92
Philip Warner, 16-Jul-2000
 
93
pjw@rhyme.com.au
 
94
 
 
95
 
 
96