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
- pg_dump -b -c -C --format=c -d -h <<hostname>> -p 5432 -U postuser -f /tmp/april_23/abc.sql abc
Expand|Select|Wrap|Line Numbers
- pg_restore -c --format=c -h <<hostname>> -p 5432 -U postuser -d sfdb /tmp/april_23/abc.sql
Traceback (most recent call last):
Expand|Select|Wrap|Line Numbers
- File "./db.py", line 122, in restore_db
- ret = app.util.executeCommand(self.cmd)
Expand|Select|Wrap|Line Numbers
- RuntimeError: pg_restore -c --format=c -h <<hostname>> -p 5432 -U postuser -d abc /tmp/april_23/abc.sql failed with exit code 256
- Std Err: pg_restore: [archiver (db)] Error while PROCESSING TOC:
- pg_restore: [archiver (db)] Error from TOC entry 5; 2615 2200 SCHEMA public postgres
- pg_restore: [archiver (db)] could not execute query: ERROR: must be owner of schema public
- Command was: DROP SCHEMA public;
- pg_restore: [archiver (db)] could not execute query: ERROR: schema "public" already exists
- Command was: CREATE SCHEMA public;
- pg_restore: [archiver (db)] Error from TOC entry 2229; 0 0 COMMENT SCHEMA public postgres
- pg_restore: [archiver (db)] could not execute query: ERROR: must be owner of schema public
- Command was: COMMENT ON SCHEMA public IS 'Standard public schema';
- pg_restore: WARNING: no privileges could be revoked for "public"
- pg_restore: WARNING: no privileges could be revoked for "public"
- pg_restore: WARNING: no privileges were granted for "public"
- pg_restore: WARNING: no privileges were granted for "public"
- WARNING: errors ignored on restore: 3
- Stdoutput:
- Unable to restore db
Thanks
Prathap