Re: cloning database

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: cloning database
Date: 2014-09-20 18:46:53
Message-ID: 1411238813219-5819805.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hubert depesz lubaczewski wrote
> On Fri, Sep 19, 2014 at 8:35 AM, Philipp Kraus &lt;

> philipp.kraus@

> &gt;
> wrote:
>
>> Is there a buildin way to clone the "database_source" with all structure
>> and data into a new database "database1..150" ?
>>
>
> assuming you're using bash shell, this should work:
>
> for i in {1..150}; do createdb -T database_source database$i; done
>
> it's not a built-in, but very close.
>
> depesz

Any advantage to this compared to using pl/pgsql via a DO command while
connected to the postgres database? Note it would require dynamic SQL
(i.e., EXECUTE).

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/cloning-database-tp5819599p5819805.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Joseph Krogh 2014-09-21 11:36:18 Strategy for moving a large DB to another machine with least possible down-time
Previous Message Adrian Klaver 2014-09-20 17:56:52 Re: can't restore database created with pg_dump