Re: [SQL] How to duplicate postgres 9.4 database - Mailing list pgsql-sql

From Igor Neyman
Subject Re: [SQL] How to duplicate postgres 9.4 database
Date
Msg-id CY1PR07MB23803BD5BF9952CF8865348DDAA40@CY1PR07MB2380.namprd07.prod.outlook.com
Whole thread Raw
In response to [SQL] How to duplicate postgres 9.4 database  (srilinux <srilinux09@gmail.com>)
Responses Re: [SQL] How to duplicate postgres 9.4 database  (srilinux <srilinux09@gmail.com>)
List pgsql-sql
-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of srilinux
Sent: Friday, July 21, 2017 3:29 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] How to duplicate postgres 9.4 database

Hi All

I want to duplicate the existing database , after reading documentation I used below command which just created
database,but did not create data 
CREATE DATABASE standby TEMPLATE template0;


my database is 35gb so dump and psql will take longer hours

is there an fastest way to copy database on same server , so that I can just modify pointing to the database and
connectto the stanby one to do any testing ? 

__________________________________________________________________________________________________________

As a TEMPLATE you should use the db that you want to copy, let's call it "source_db":

CREATE DATABASE standby TEMPLATE source_db;

Be aware, that when this statement runs there should be no user connections to source_db.

Regards,
Igor Neyman






pgsql-sql by date:

Previous
From: srilinux
Date:
Subject: [SQL] How to duplicate postgres 9.4 database
Next
From: srilinux
Date:
Subject: Re: [SQL] How to duplicate postgres 9.4 database