473,386 Members | 1,873 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,386 software developers and data experts.

pg_restore doesn't work for postgresql 7.2.3

Hello.

I'm developing an application and it has to backup and restore database using pg_dump & pg_restore.

the database is PostgreSql7.2.3 and pg_dump.exe & pg_restore.exe is from pg admin III.

The command I've used for backup and restore are:
pg_dump -i -h 172.17.5.82 -p 5432 -U livo -F t -c -C -D -v -f c:\backup.tar livo
pg_restore -i -c -F t -v -h 172.17.5.82 -p 5432 -U livo -d livo -v c:\backup.tar

it backs up fine, but errors occur while restoring.

the error says: could not set search_path to "public", parse error at or near "public", could not execute query. Command was:
DROP TABLE public.myTable;
could not execute query. relation "myTable" already exists:

It fails to drop an table because it doesnt understand "public" and copies the rows in table myTable. Therefore, it's end up with doubled duplicated rows.


I guessed it should be fine if I add "public" to an environment variable 'search_path', but I just found that 'search_path' was first introduced at PostgreSQL 7.3. ( mine is 7.2.3 ).


It's just simple backup & restore. just backup several tables and restore.
no functions and no complicated work.

I suggested that let's just manually(?) drop the tables in the application before restoring but my boss said it's not an option.

Is there any smart solution on this?

Thank you.
Apr 17 '07 #1
2 3741
michaelb
534 Expert 512MB
Looks like you have an array of problems.
You're right to say that search_path would be useless for v.7.2, and this is because the concept of schema wasn't introduced until v.7.3.
So why do you have this public qualifier in your dump?
First, you are using the wrong versions of pg_dump and pg_restore - you should be using those that came with the database.
Second, even if pg_dump and pg_restore that came with pgAdmin III are capable of working with the old databases, you should never use the -i flag. It means "Ignore version mismatch" and it is harmful in your case.

Next, lets look at some other flags that you pass to pg_dump and pg restore.

pg_dump -i -h 172.17.5.82 -p 5432 -U livo -F t -c -C -D -v -f c:\backup.tar livo
The -C and -c flags are mutually exclusive, the only reason that you are not getting an error right there, because neither of them makes sense unless you're using the plain format; and you are using tar (-F t)
The -D flag should not cause a problem, but do you really need it?
It can make the restore process quite slow.


pg_restore -i -c -F t -v -h 172.17.5.82 -p 5432 -U livo -d livo -v c:\backup.tar
The -i flag should not be here. It means "Restore definition for named index only", and you are not passing any index-name to it.
The -c flag is just ignored because of the format of your data-dump.

One approach you may consider is to use pg_dump to create a plain-text datafile. In this case you can use the -C option.

Then use a small wrapper script which you submit via psql.
The script may look like this:

Expand|Select|Wrap|Line Numbers
  1. -- connect to the template
  2. \connect template1
  3. -- drop database which needs to be restored
  4. drop database livo;
  5.  
  6. -- create database (encoding may vary)
  7. -- this is not needed if pg_dump was created with the -C option
  8. CREATE DATABASE livo WITH TEMPLATE = template0 ENCODING = 'UNICODE';"
  9. \connect livo
  10.  
  11. -- finally import the dump-file
  12. \i  <path_name_of_backup>
  13.  
  14. --  optionally update statistics for faster queries
  15. vacuum analize;
  16.  
Look at these links for more information:

http://www.postgresql.org/docs/7.2/static/backup.html
http://www.postgresql.org/docs/7.2/s...pp-pgdump.html
http://www.postgresql.org/docs/7.2/s...pgrestore.html
Apr 18 '07 #2
Thank you very much.

It really helped.
Jun 11 '07 #3

Sign in to post your reply or Sign up for a free account.

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,...
7
by: Howard Lowndes | last post by:
My situation is that I am interacting PHP 4.1.2 to PostgreSQL 7.2.2 I have no difficulty inserting and managing BLOBs into the Large Object system table, and I have a user table called images...
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...
7
by: Tim Penhey | last post by:
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...
1
by: Phil Endecott | last post by:
Dear Postgresql people, For the first time I'm trying to use pg_restore to do a partial restore. It looks as if it should be easy: pg_restore -l, filter out the required tables, then pg_restore...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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...

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.