473,385 Members | 2,028 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,385 software developers and data experts.

Unable to restore postgres-dump-Version-8.2.4

Hi All,

I have a python script which takes dump of postgres and restores the same.

When i take a dump there is no problem.
command to take dump:
Expand|Select|Wrap|Line Numbers
  1. pg_dump -b -c -C --format=c -d -h <<hostname>> -p 5432 -U postuser -f /tmp/april_23/abc.sql abc
Restore command:
Expand|Select|Wrap|Line Numbers
  1. pg_restore -c --format=c -h <<hostname>> -p 5432 -U postuser -d sfdb /tmp/april_23/abc.sql
While restoring the dump i got into following errors...

Traceback (most recent call last):
Expand|Select|Wrap|Line Numbers
  1.    File "./db.py", line 122, in restore_db
  2.     ret = app.util.executeCommand(self.cmd)
Expand|Select|Wrap|Line Numbers
  1.  
  2.  RuntimeError: pg_restore -c --format=c -h <<hostname>> -p 5432 -U postuser -d abc /tmp/april_23/abc.sql failed with exit code 256
  3. Std Err: pg_restore: [archiver (db)] Error while PROCESSING TOC:
  4. pg_restore: [archiver (db)] Error from TOC entry 5; 2615 2200 SCHEMA public postgres
  5. pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of schema public
  6.     Command was: DROP SCHEMA public;
  7. pg_restore: [archiver (db)] could not execute query: ERROR:  schema "public" already exists
  8.     Command was: CREATE SCHEMA public;
  9. pg_restore: [archiver (db)] Error from TOC entry 2229; 0 0 COMMENT SCHEMA public postgres
  10. pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of schema public
  11.     Command was: COMMENT ON SCHEMA public IS 'Standard public schema';
  12. pg_restore: WARNING:  no privileges could be revoked for "public"
  13. pg_restore: WARNING:  no privileges could be revoked for "public"
  14. pg_restore: WARNING:  no privileges were granted for "public"
  15. pg_restore: WARNING:  no privileges were granted for "public"
  16. WARNING: errors ignored on restore: 3
  17.  
  18. Stdoutput:
  19.  
  20. Unable to restore db
Any help would be of great.

Thanks
Prathap
Apr 23 '08 #1
2 7287
rski
700 Expert 512MB
I'm afraid you should give more information but this error is interesting
"ERROR: must be owner of schema public Command was: DROP SCHEMA public;".
Who did backup and who is trying to restore. What are database privileges. Why are you trying to delete public schema?
Apr 23 '08 #2
I'm afraid you should give more information but this error is interesting

Who did backup and who is trying to restore. What are database privileges. Why are you trying to delete public schema?
backup and restore are done by "postgres" user. I have just incorporated the pgsq_restore snippet in my python script.

The python script is invoked as 'root' which does the dump and restore.
Code snippet:
Expand|Select|Wrap|Line Numbers
  1.  def dump_db(self):
  2.         if not os.path.exists(self.db_backup_file_path):
  3.             try:
  4.                 os.makedirs(self.db_backup_file_path)
  5.             except:
  6.                 self.printErrorAndExit("Unable to create path for DB backup: %s " %self.db_backup_file_path, 3)
  7.  
  8.         if self.db_name != '':
  9.             try:
  10.                 self.cmd = 'pg_dump -b -c -C --format=c -d -h '+ self.db_host
  11.                 self.cmd = self.cmd +' -p '+ self.db_port
  12.                 self.cmd = self.cmd +' -U '+ self.db_user
  13.                 self.cmd = self.cmd +' -f '+ self.db_backup_file
  14.                 self.cmd = self.cmd +' '+ self.db_name
  15.                 print self.cmd
  16.                 ret = app.util.executeCommand(self.cmd)
  17.             except:
  18.                 self.printErrorAndExit("Unable to take DB backup\n", 4)
  19.  
  20. ======================================================
  21.   # restores database
  22.     def restore_db(self):
  23.         if self.force:
  24.             option = 'YES'
  25.             print "Force option selected, so proceeding to replace the existing data by the dump you have selected."
  26.         else:
  27.             option  = app.util.readFromUser("Existing data will be replaced by the dump you have selected. Do you want to proceed? YES/NO", 'YES',  ['YES', 'NO'])
  28.             if option == 'YES':
  29.                 pass
  30.             else:
  31.                 self.printErrorAndExit("Exiting restore db on user request..")
  32.  
  33.         if not os.path.exists(self.db_backup_file):
  34.             self.printErrorAndExit("Unable to find DB backup file: %s " %self.db_backup_file_path, 5)
  35.  
  36.         if self.db_name != '':
  37.             try:
  38.                 self.cmd = 'pg_restore -c --format=c -h '+ self.db_host
  39.                 self.cmd = self.cmd +' -p '+ self.db_port
  40.                 self.cmd = self.cmd +' -U '+ self.db_user
  41.                 self.cmd = self.cmd +' -d '+ self.db_name
  42.                 self.cmd = self.cmd + ' ' + self.db_backup_file
  43.                 print self.cmd
  44.                 print "Restoring db, please wait...."
  45.                 ret = app.util.executeCommand(self.cmd)
  46.             except:
  47.                 print " ".join(app.util.getStackTraceAndException())
  48.                 self.printErrorAndExit("Unable to restore db\n", 6)
  49.         else:
  50.             self.printErrorAndExit("Unable to restore db, due to empty db name\n", 7)
Apr 23 '08 #3

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

Similar topics

7
by: Christopher Murtagh | last post by:
Greetings, I just had to dump and restore one of my DBs (7.4RC2), and I got an interesting message. I first did: pg_dump dbname > db_restore.sql Then at console did the following:
3
by: Frank Stefani | last post by:
Hi, due to an upgrade from a former DB2 v7.02, I backed up an entire database to a file in the local filesystem under Linux. I removed the old version completely an installed a fresh v8.1 DB2....
4
by: David A. Ulevitch | last post by:
Hi fellow pgsql users, I am helping my university's student union get back up and running after some major server issues they had. They had serious disk issues on a server, but not on the /var...
1
by: Bob Powell | last post by:
** High Priority ** Hello everyone, I have a restore file created by pg_dumpall. The restore file has two users associated with ownership of tables. The postgres user and a user called...
0
by: vicky | last post by:
Hello Experts, Trying to run sample Postgrel's ECPG(Embedded SQL)programs on RHL 9.0. Im unable to connect to PostgreSQL database (sirishadb) when I run the program .... # su postgres...
12
by: zuhans | last post by:
-------- Original-Nachricht -------- Betreff: backup and restore just with use of jdbc? Datum: Sun, 13 Jun 2004 10:23:53 +0200 Von: zuhans@iname.com <zuhans@iname.com> An:...
4
by: newladder | last post by:
Hi all, Iam struck with one of the problem with postgres. Please help me out.... Iam trying to connect to connect to postgres database on remote machine with the IP address 10.2.1.4. Iam unable...
0
by: rkalaria | last post by:
I have to migrate a postgres database to oracle. so i want to know that how it will be happen without using any third party tools.
3
by: varathasiva | last post by:
Dear All, I want take a incremental backup and restore in postgres sql throught command.If you have any ideas reply me.Advance thanks to all. Kindly Regards Siva
1
by: mlaris | last post by:
Howdy, We are experiencing a bizarre problem under Linux attempting to restore a DB2 database. The backup was created on this machine, and is being restored to the same machine, but changing the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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.