pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Sathish Kumar <satcse88@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Postgresql Duplicate DB
Date: Mon, 11 Feb 2019 12:16:43 +0100
Message-ID: <f596dc37f9e2a3a28b382cc8d7dbe51f26d9d415.camel@cybertec.at> (raw)
In-Reply-To: <CANa_DOjLgEZ-ZFfMC+qTNUZf0CEsRS8UCEksFKCAagwqQuepsA@mail.gmail.com>
References: <CANa_DOjLgEZ-ZFfMC+qTNUZf0CEsRS8UCEksFKCAagwqQuepsA@mail.gmail.com>

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





view thread (3+ messages)

Message-ID: <f596dc37f9e2a3a28b382cc8d7dbe51f26d9d415.camel@cybertec.at>
Permalink:  ../f596dc37f9e2a3a28b382cc8d7dbe51f26d9d415.camel@cybertec.at/
Also on:    postgresql.org/message-id/f596dc37f9e2a3a28b382cc8d7dbe51f26d9d415.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, satcse88@gmail.com
  Subject: Re: Postgresql Duplicate DB
  In-Reply-To: <f596dc37f9e2a3a28b382cc8d7dbe51f26d9d415.camel@cybertec.at>
  References: <CANa_DOjLgEZ-ZFfMC+qTNUZf0CEsRS8UCEksFKCAagwqQuepsA@mail.gmail.com> <f596dc37f9e2a3a28b382cc8d7dbe51f26d9d415.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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