pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jaume Sabater <jsabater@linuxsilo.net>
To: pgsql-admin@postgresql.org
Subject: pg_dump and pg_restore with different owners
Date: Thu, 19 Apr 2007 11:56:46 +0200
Message-ID: <46273CDE.50401@linuxsilo.net> (raw)

Hello everyone!

We have a two servers, "devel" and "live", both running PostgreSQL 
8.1.8. At the devel server there is the database "ots_devel" owned by 
user "ots_devel". At the live server there is the database "ots_live" 
owned by the user "ots_live". They are normal users, with no ability to 
create databases or roles. I have access as superuser.

I want to dump the database "ots_devel", then copy it to the live server 
and restore it under a different name ("ots_live") and owned by a 
different user "ots_live". These are the commands I am using:

- At the devel server:

pg_dump --oids --no-owner --format=c --file=ots_devel.bak ots_devel

- At the live server:

createuser --no-superuser --no-createdb --no-createrole --pwprompt ots_live

createdb --encoding=UTF-8 --owner=ots_live ots_live

pg_restore --no-owner --dbname=ots_live ots_devel.bak

If I do this, there is no warning, there is no error. But the user 
ots_live does not have the right permissions over the tables in the 
database. He is not the owner of those objects or the permissions are 
not right.

Then I tried restoring this way:

pg_restore --no-owner --dbname=ots_live  --host=127.0.0.1 -U ots_live -W 
ots_devel.bak

But I got these errors:

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3751; 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
pg_restore: WARNING:  no privileges could be revoked
pg_restore: WARNING:  no privileges were granted
pg_restore: WARNING:  no privileges were granted
WARNING: errors ignored on restore: 1

What I want is that user "ots_live" is the new only owner of everything 
inside the database "ots_live". I think that the problem is not when 
working inside the database "ots_live", but when updating the schemas, 
but I don't know how to prevent that from happening.

I've read about authorization, but I don't know how to apply it to my case.

Any hints? Thanks in advance.

-- 
Jaume Sabater
http://linuxsilo.net/

"Ubi sapientas ibi libertas"



view thread (3+ messages)  latest in thread

Message-ID: <46273CDE.50401@linuxsilo.net>
Permalink:  ../46273CDE.50401@linuxsilo.net/
Also on:    postgresql.org/message-id/46273CDE.50401@linuxsilo.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: jsabater@linuxsilo.net
  Subject: Re: pg_dump and pg_restore with different owners
  In-Reply-To: <46273CDE.50401@linuxsilo.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox