473,748 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_ha ndler() postgres
pg_restore: [archiver (db)] could not execute query: ERROR: function
"plpgsql_call_h andler" already exists with same argument types
Command was: CREATE FUNCTION plpgsql_call_ha ndler() RETURNS
language_handle r
AS '$libdir/plpgsql', 'plpgsql_call_h andler'
LANGUAG...
pg_restore: [archiver (db)] Error from TOC Entry 18; 1255 17229 FUNCTION
plpgsql_validat or(oid) postgres
pg_restore: [archiver (db)] could not execute query: ERROR: function
"plpgsql_valida tor" already exists with same argument types
Command was: CREATE FUNCTION plpgsql_validat or(oid) RETURNS void
AS '$libdir/plpgsql', 'plpgsql_valida tor'
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_ha ndler VALIDATOR plpgsql_validat or;

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*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #1
7 7767
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 YourEmailAddres sHere" to ma*******@postg resql.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*******@postg resql.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.a t> 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*******@postg resql.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*******@postg resql.org

Nov 23 '05 #8

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

Similar topics

1
3761
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 mydb > mydb_dump > CREATE DATABASE mydb_restore TEMPLATE template0
0
1493
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 7.3.3 so, i dumped all the databases from the production db and reloaded on the test,
0
2090
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, PostgreSQL 7.3.3 and Mammoth PostgreSQL 7.3.4 . The command being used to backup the data is: /usr/local/pgsql/bin/pg_dump dominion -h localhost --superuser=postgres --create --format=c -b -o -f /backups/backup.sql.tar.gz The command has also...
14
3718
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 created in serial? How about this new, multi-threaded way of doing the pg_restore: 0. On the command line, you specify how many threads you want.
1
2203
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 character 144 pg_restore: *** aborted because of error The line in question is:
6
4975
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 2.3G in size. The dump, which seemed to run smoothly, was created using the -Fc option. When I perform the restore, the following error occurs before the pg_restore fails: pg_restore: error during file seek: Invalid argument pg_restore: ***...
1
1848
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: pg_restore: executing SEQUENCE SET t_tab_kurs_template_id_seq pg_restore: could not execute query: ERROR: relation "t_tab_kur s_template_id_seq" does not exist pg_restore: *** aborted because of error
3
4919
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 FreeBSD 4.10-STABLE or a: pg_restore in malloc(): error: allocation failed Abort (core dumped) error on FreeBSD 5.2.1-P9 (RELEASE) In both cases I have increased the max data segment size to 1.5GB and the max stack size to 768M or so.
1
10223
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 tableA.dump aparently well, but after running pg_restore without errors I cannot find any "tableB", what am I doing wrong?
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.