pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_dump and pg_restore with different owners
3+ messages / 2 participants
[nested] [flat]

* pg_dump and pg_restore with different owners
@ 2007-04-19 09:56  Jaume Sabater <jsabater@linuxsilo.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Jaume Sabater @ 2007-04-19 09:56 UTC (permalink / raw)
  To: pgsql-admin

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"



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_dump and pg_restore with different owners
@ 2007-04-23 11:43  Jaume Sabater <jsabater@linuxsilo.net>
  parent: Jaume Sabater <jsabater@linuxsilo.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Jaume Sabater @ 2007-04-23 11:43 UTC (permalink / raw)
  To: pgsql-admin

Jaume Sabater wrote:

> Hello everyone!

I am resending this email to see whether I have better luck now. I've 
been digging the Internet with no luck for the past few days.

> 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"



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_dump and pg_restore with different owners
@ 2007-04-23 14:49  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jaume Sabater <jsabater@linuxsilo.net>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2007-04-23 14:49 UTC (permalink / raw)
  To: Jaume Sabater <jsabater@linuxsilo.net>; +Cc: pgsql-admin

Jaume Sabater <jsabater@linuxsilo.net> writes:
>> 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

You can ignore these.  --no-owner plus do the restore as the new owner
is the correct procedure.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-04-23 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-19 09:56 pg_dump and pg_restore with different owners Jaume Sabater <jsabater@linuxsilo.net>
2007-04-23 11:43 ` Jaume Sabater <jsabater@linuxsilo.net>
2007-04-23 14:49   ` Tom Lane <tgl@sss.pgh.pa.us>

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