restoring database

Started by Lucas Lainover 22 years ago4 messagesgeneral
Jump to latest
#1Lucas Lain
lainl@aconectarse.com

Hi everybody ... i need to restore only one database from a pg_dumpall backup
file... how can i do it?

Thanks a lot !

#2Oliver Elphick
olly@lfix.co.uk
In reply to: Lucas Lain (#1)
Re: restoring database

On Mon, 2003-12-22 at 14:51, Lucas Lain wrote:

Hi everybody ... i need to restore only one database from a pg_dumpall backup
file... how can i do it?

If it's a plain text dump, make a copy of the backup file. Edit the
copy and delete everything that doesn't relate to the database to be
restored.

If you dumped in tar or special format, I believe you can use
pg_restore -d dbname
but I haven't done that myself and am not sure if I'm interpreting the
manpage correctly.

--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"And there were in the same country shepherds abiding
in the field, keeping watch over their flock by night.
And, lo, the angel of the Lord came upon them, and the
glory of the Lord shone around them; and they were
sore afraid. And the angel said unto them, " Fear not;
for behold I bring you good tidings of great joy which
shall be to all people. For unto you is born this day
in the city of David a Saviour, which is Christ the
Lord." Luke 2:8-11

#3Lucas Lain
lainl@aconectarse.com
In reply to: Oliver Elphick (#2)
Re: restoring database

If it's a plain text dump, make a copy of the backup file. Edit the
copy and delete everything that doesn't relate to the database to be
restored.

it's quite large to do this ...

If you dumped in tar or special format, I believe you can use
pg_restore -d dbname
but I haven't done that myself and am not sure if I'm interpreting the
manpage correctly.

this database is only for connection ..

i like the split solution ... i will try

#4Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Lucas Lain (#3)
Re: restoring database

On Mon, Dec 22, 2003 at 08:14:51PM -0300, Lucas Lain wrote:

If it's a plain text dump, make a copy of the backup file. Edit the
copy and delete everything that doesn't relate to the database to be
restored.

it's quite large to do this ...

Maybe you could try getting the line numbers for the data you want using
grep (be sure to anchor the patterns with ^ to make the search faster),
and then extract the data using either awk (see NR) or perl (see $.).
This way you don't have to open the dump with an editor, which would
load the whole file in memory.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"La fuerza no est� en los medios f�sicos
sino que reside en una voluntad indomable" (Gandhi)