473,574 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to restore postgres-dump-Version-8.2.4

2 New Member
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
  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
  18. Stdoutput:
  20. Unable to restore db
Any help would be of great.

Apr 23 '08 #1
2 7311
700 Recognized Expert Contributor
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
2 New Member
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)
  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)
  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..")
  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)
  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

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:
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. After initialisation, I tried to restore the old database into the new DB2 version with db2cc or db2 command line interface. The process fails...
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 partition where all of the /var/lib/postgres/data files were. I was able to recover all of it, at the file-system level. The old machine and the...
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 nsadmin. When I attempt to restore this it won't create my call_handlers because it's not the postgres user. If I attempt to restore under the nsadmin
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 (enter)
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: pgsql-general@postgresql.org hello,
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 Iam unable to get connected. below is my script. <?php $connection_string = 'DRIVER={PostgreSQL};SERVER=;DATABASE=Admin';
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.
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
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 name of the database, and redirecting the tablespaces. The system is running DB2 Express C V9.5 and RHEL5 with latest updates The restore...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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...
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...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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...

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.