Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt9aE-0004e7-TW for pgsql-general@arkaria.postgresql.org; Mon, 11 Feb 2019 11:17:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gt9aD-0005MF-Mc for pgsql-general@arkaria.postgresql.org; Mon, 11 Feb 2019 11:17:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt9aD-0005GU-AF for pgsql-general@lists.postgresql.org; Mon, 11 Feb 2019 11:17:05 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt9aA-00071F-Hc for pgsql-general@lists.postgresql.org; Mon, 11 Feb 2019 11:17:04 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 17926A19AB; Mon, 11 Feb 2019 12:17:00 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id Cf4_wbXJJ4Gr; Mon, 11 Feb 2019 12:16:43 +0100 (CET) Message-ID: Subject: Re: Postgresql Duplicate DB From: Laurenz Albe To: Sathish Kumar , pgsql-general@lists.postgresql.org Date: Mon, 11 Feb 2019 12:16:43 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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