Re: pg_dump and pg_restore with different owners

From: Jaume Sabater <jsabater(at)linuxsilo(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: pg_dump and pg_restore with different owners
Date: 2007-04-23 11:43:15
Message-ID: 462C9BD3.6090405@linuxsilo.net
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: 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"

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2007-04-23 14:21:03 Re: CESTLOG: statistics buffer is full
Previous Message Achakzai, Omar 2007-04-23 10:56:22 CESTLOG: statistics buffer is full