Unix Technical Forum

how to get pg_restore to continue if an error occurs

This is a discussion on how to get pg_restore to continue if an error occurs within the Pgsql General forums, part of the PostgreSQL category; --> I'm using 7.4.19 utils on Centos 5 to move a database from one shared hosting server to another shared ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 09:34 PM
Chris Velevitch
 
Posts: n/a
Default how to get pg_restore to continue if an error occurs

I'm using 7.4.19 utils on Centos 5 to move a database from one shared
hosting server to another shared hosting server.

The dump and restore options that I used are:-

pg_dump -O -v -F c
pg_restore -c -O -x -v

pg_restore aborts the restore (with a return code=1) when trying to
'comment schema "public"', which is because the schema is not owned by
the database owner.

1. How do I get pg_restore to simply ignore this error and continue
the restore to completion?
2. Is it ok to have the schema "public" owned by the owner of the database?
3. How do I tell if the restore is complete as a cursory look seems to
indicate the restore is complete?


Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
m: 0415 469 095
www.flashdev.org.au

Sydney Flash Platform Developers Group
April meeting: TBD
Date: Mon 28th April 6pm for 6:30 start
Details soon

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 09:34 PM
Chris Velevitch
 
Posts: n/a
Default Re: how to get pg_restore to continue if an error occurs

I guess this is something that is not a common occurrence as no one
has yet to suggest a solution.

So it looks like I'm going to have to answer my own question.

Firstly, I'd like to say how well thought out is the design of the
dump/restore utils.

If you use the -F c option in pg_dump, this creates what is called a
custom format dump file. This basically creates dump segments which
can be referred to by ID, which can seem by using pg_restore -l to
list the content of the archive. So in my case, the list is:-

;
; Archive created at Mon Apr 14 17:20:44 2008
; dbname: thedb
; TOC Entries: 66
; Compression: -1
; Dump Version: 1.7-0
; Format: CUSTOM
; Integer: 4 bytes
; Offset: 8 bytes
;
;
; Selected TOC Entries:
;
4; 2200 ACL public postgres
5; 250601 TABLE table1 ownername
6; 250603 TABLE table2 ownername
....
3; 2200 COMMENT SCHEMA public postgres

So by saving this output and commenting out (using the ';') the
entries you what ignored, you can then run the pg_restore util with
the --use-list=list-file and only the uncommented items will be
restored.

Pretty neat.


Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
m: 0415 469 095
www.flashdev.org.au

Sydney Flash Platform Developers Group
April meeting: TBD
Date: Mon 28th April 6pm for 6:30 start
Details soon

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:25 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com