Re: Restore backup of database to new database name

From: Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>
To: sam turnbull <samturnbull73(at)gmail(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Restore backup of database to new database name
Date: 2015-06-26 19:06:09
Message-ID: CAJghg4K5s=bAbrap7Yhks8kq2sRqA=HFZ8U5SEaXMa8muPVLnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Fri, Jun 26, 2015 at 10:31 AM, sam turnbull <samturnbull73(at)gmail(dot)com>
wrote:

> backup database - Test
> User(owner) - A
>
> Restore to new database - Test1
> under new user - B

You can either create your dump file with --no-owner (or -O), or use a
binary format and use --no-owner | -O on pg_restore. Then, when you restore
you must do it connecting as user B.

Example with pg_restore:

- Dump:

$ pg_dump -Fc -d Test -f /path/to/test.dump

- Restore:

$ createuser B
$ createdb --template=template0 --owner=B Test1
$ pg_restore --no-owner -U B -d Test1 /path/to/test.dump

And you are done. You might also want to include --no-privileges, but that
depends.

Regards,
--
Matheus de Oliveira

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Kevin Grittner 2015-06-26 19:40:18 Re: Does VACUUM FULL need ANALYZE ?
Previous Message sam turnbull 2015-06-26 13:31:08 Restore backup of database to new database name