Re: Postgresql Duplicate DB

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Sathish Kumar <satcse88(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Postgresql Duplicate DB
Date: 2019-02-11 11:16:43
Message-ID: f596dc37f9e2a3a28b382cc8d7dbe51f26d9d415.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sathish Kumar wrote:
> I would like to duplicate our existing db on the same server, what will be the faster way to achieve it.

If it is in the same database cluster, you can use

CREATE DATABASE newdb TEMPLATE olddb;

Make sure nobody is connected to "olddb" when you do that.

If you want to clone a whole database cluster, you can run

pg_basebackup -D /new/cluster/directory --wal-method=stream

and recover the new cluster with "restore_command = 'true'".

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Aguayo Garcia-Rada 2019-02-11 13:21:23 Re: bdr replication breaks down
Previous Message Alvaro Aguayo Garcia-Rada 2019-02-11 11:16:34 RE: Postgresql Duplicate DB