473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

pg_restore peculiarities

Maybe it's just me, but I can't seem to get pg_restore to restore a
database...

I am running 8.0 beta 2 (using the dev3 installer) on Windows XP.

I created a very simple database with one table and one function and
dumped it out using:

pg_dump -U postgres -F c -f test.dump test

This worked fine, although the compressed file was 120 K (ish).
Although this might have something to do with the database having 258
functions and a number of operators and operator classes (visible
through pgAdmin III). Following the examples in the docs, I created a
new database and tried to restore into that using

pg_restore -U postgres -d test_restored test.dump

But it gives about 117K of error messages starting with:
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC Entry 17; 1255 17228 FUNCTION
plpgsql_call_handler() postgres
pg_restore: [archiver (db)] could not execute query: ERROR: function
"plpgsql_call_handler" already exists with same argument types
Command was: CREATE FUNCTION plpgsql_call_handler() RETURNS
language_handler
AS '$libdir/plpgsql', 'plpgsql_call_handler'
LANGUAG...
pg_restore: [archiver (db)] Error from TOC Entry 18; 1255 17229 FUNCTION
plpgsql_validator(oid) postgres
pg_restore: [archiver (db)] could not execute query: ERROR: function
"plpgsql_validator" already exists with same argument types
Command was: CREATE FUNCTION plpgsql_validator(oid) RETURNS void
AS '$libdir/plpgsql', 'plpgsql_validator'
LANGUAGE c;
pg_restore: [archiver (db)] Error from TOC Entry 535; 16402 17230
PROCEDURAL LANGUAGE plpgsql
pg_restore: [archiver (db)] could not execute query: ERROR: language
"plpgsql" already exists
Command was: CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER
plpgsql_call_handler VALIDATOR plpgsql_validator;

Even trying to restore data only gives duplicate key constraint errors.

Now this might seem simple, but all I want to be able to do is to backup
all the data in about 20 or so tables (all the non-system tables in a
DB, and their associated sequences), and be able to restore the data in
the tables back to that state at a later date. Now I assumed that
pg_dump and pg_restore would be the easiest ways to do this, but I can't
even seem to get a simple case working.

Does anyone know the magic word to get this working?

Thanks
Tim
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #1
7 7740
Tim Penhey <ti*@penhey.net> writes:
Maybe it's just me, but I can't seem to get pg_restore to restore a
database...


It looks to me like you have a bunch of stuff in template1, which is
being duplicated into your test_restored DB and then is interfering
with the restoration of similarly-named objects.

Create the empty database using template0 as template, instead, and
then the restore will work.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #2
Tom Lane wrote:
Tim Penhey <ti*@penhey.net> writes:

Maybe it's just me, but I can't seem to get pg_restore to restore a
database...

Ah, that appears to be it.

As long as I tell the restore command to clean as it goes it seems OK.

How does pg_dump handle referential integrity? Particularly with the
restoring of tables where the integrity is needed?

Tim

Nov 23 '05 #3
Tim Penhey wrote:
Tom Lane wrote:
Tim Penhey <ti*@penhey.net> writes:

Maybe it's just me, but I can't seem to get pg_restore to restore a
database...

Ah, that appears to be it.

As long as I tell the restore command to clean as it goes it seems OK.

How does pg_dump handle referential integrity? Particularly with the
restoring of tables where the integrity is needed?

Tim


Oops, cut wrong bit out ;-)
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #4
Tom Lane wrote:
It looks to me like you have a bunch of stuff in template1, which is
being duplicated into your test_restored DB and then is interfering
with the restoration of similarly-named objects.

Create the empty database using template0 as template, instead, and
then the restore will work.

regards, tom lane

Which does bring another question forward:

What is all the stuff that has been added to template1 given it is a
clean install of version 8 beta 2 dev 3?

The only thing it asked in the installer was what languages to add to
the template, and I chose plpgsql only.

Thanks,
Tim

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #5
Tim Penhey wrote:
Which does bring another question forward:

What is all the stuff that has been added to template1 given it is a
clean install of version 8 beta 2 dev 3?

The only thing it asked in the installer was what languages to add to
the template, and I chose plpgsql only.


I also thought so, but it's not the case. The installer puts all contrib
modules into template1 that are included with the package and selected for
install (at the module selection screen)... the default is to install all.

I would rather like the installer to only install the dlls etc. and not
throw everything into template1... perhaps add a feature request at
pgFoundry?

Best Regards,
Michael Paesold
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #6
"Michael Paesold" <mp******@gmx.at> writes:
Tim Penhey wrote:
The only thing it asked in the installer was what languages to add to
the template, and I chose plpgsql only.
I also thought so, but it's not the case. The installer puts all contrib
modules into template1 that are included with the package and selected for
install (at the module selection screen)... the default is to install all. I would rather like the installer to only install the dlls etc. and not
throw everything into template1... perhaps add a feature request at
pgFoundry?


Without taking a position on what the Windows installer ought to do ...
*whenever* you are restoring a pg_dump dump, you ought to do so into
an empty database cloned from template0. If the documentation doesn't
say that in enough places, suggest some more.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #7
Tom Lane wrote:
Without taking a position on what the Windows installer ought to do ...
*whenever* you are restoring a pg_dump dump, you ought to do so into
an empty database cloned from template0. If the documentation doesn't
say that in enough places, suggest some more.

Right. If, as Tom says, that restores should be into an empty database
cloned form template0, what then is the best way to provide a data
restore facility to a user though a back end system (Tomcat & JDBC) that
will have connections open to the database that you are trying to
restore to?

Tim

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sam | last post by:
I'm having trouble restoring databases that have to lo type installed in /contrib/lo. The dump seems to work just fine, I get no errors when I execute the following command #pg_dump -Fc -o -b...
0
by: andy morrow | last post by:
hi, fairly new to postgres admin stuff...... i have a production machine that is running postgresql 7.1.3 also, there's a test machine which already had 7.0.3, and which i newly installed...
0
by: Joshua D. Drake | last post by:
Alright, we are testing pg_restore while restoring a 7GB database. This database has about 6GB of large objects and about 1Gb of textual data. The problem has been verified on PostgreSQL 7.3.2,...
14
by: Ron Johnson | last post by:
Hi, While on the topic of "need for in-place upgrades", I got to think- ing how the pg_restore could be speeded up. Am I wrong in saying that in the current pg_restore, all of the indexes are...
1
by: nednieuws | charles | last post by:
What does this error mean: pg_restore: creating TABLE author pg_restore: creating SEQUENCE author_id pg_restore: could not execute query: ERROR: parser: parse error at or near "BY" at...
6
by: Mike Charnoky | last post by:
Hello, I am currently using PostgreSQL v7.3.4 on a RedHat 8.0 system (2.4.23 kernel) using the ext3 filesystem. I am experiencing problems when performing a pg_restore using a file which is...
1
by: Plant Thomas | last post by:
Hi, I have a problem restoring a database from Postgresql 7.3 ( backup created with 'pg_dump -Ft -b > test.tar' ) to a new database on PostgreSQL 7.4.3 on Cygwin. I get the following error: ...
3
by: Sven Willenberger | last post by:
Created a pg_dump with Fc (custom format compression) that resulted in a 300+MB file. Now trying to pg_restore this thing fails with either an out of memory error (as in the subject line) on...
1
by: ruben | last post by:
Hi: I'm trying to dump tableA and restore it to tableB: $ ./pg_dump -Fc -t tableA databaseA -f tableA.dump -v $ ./pg_restore -t tableB -d databaseA tableA.dump -v pg_dump creates...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.