agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
How to duplicate postgres 9.4 database
4+ messages / 3 participants
[nested] [flat]

* How to duplicate postgres 9.4 database
@ 2017-07-21 19:28  srilinux <srilinux09@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: srilinux @ 2017-07-21 19:28 UTC (permalink / raw)
  To: pgsql-sql

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 connect to the stanby one to do any
testing ?



--
View this message in context: http://www.postgresql-archive.org/How-to-duplicate-postgres-9-4-database-tp5972442.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How to duplicate postgres 9.4 database
@ 2017-07-21 20:07  Igor Neyman <ineyman@perceptron.com>
  parent: srilinux <srilinux09@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Igor Neyman @ 2017-07-21 20:07 UTC (permalink / raw)
  To: srilinux <srilinux09@gmail.com>; 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 connect to 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





-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How to duplicate postgres 9.4 database
@ 2017-07-22 23:43  srilinux <srilinux09@gmail.com>
  parent: Igor Neyman <ineyman@perceptron.com>
  0 siblings, 1 reply; 4+ messages in thread

From: srilinux @ 2017-07-22 23:43 UTC (permalink / raw)
  To: pgsql-sql

Thank you very much


I will try it , how much time will it take for 35gb database ? is this
method suggest able for a 35gb database ?

Thank you
Sri

On Fri, Jul 21, 2017 at 4:08 PM, Igor Neyman [via PostgreSQL] <
ml+s1045698n5972447h56@n3.nabble.com> wrote:

> -----Original Message-----
> From: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5972447&i=0; [mailto:[hidden
> email] <http:///user/SendEmail.jtp?type=node&node=5972447&i=1;] On Behalf
> Of srilinux
> Sent: Friday, July 21, 2017 3:29 PM
> To: [hidden email] <http:///user/SendEmail.jtp?type=node&node=5972447&i=2;
> 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 connect to 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
>
>
>
>
>
> --
> Sent via pgsql-sql mailing list ([hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5972447&i=3;)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://www.postgresql-archive.org/How-to-duplicate-postgres-9-4-database-
> tp5972442p5972447.html
> To unsubscribe from How to duplicate postgres 9.4 database, click here
> <http://www.postgresql-archive.org/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=597244...;
> .
> NAML
> <http://www.postgresql-archive.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21...;
>




--
View this message in context: http://www.postgresql-archive.org/How-to-duplicate-postgres-9-4-database-tp5972442p5972497.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: How to duplicate postgres 9.4 database
@ 2017-07-25 21:07  Scott Marlowe <scott.marlowe@gmail.com>
  parent: srilinux <srilinux09@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Scott Marlowe @ 2017-07-25 21:07 UTC (permalink / raw)
  To: srilinux <srilinux09@gmail.com>; +Cc: pgsql-sql

On Sat, Jul 22, 2017 at 4:43 PM, srilinux <srilinux09@gmail.com> wrote:
> Thank you very much
>
>
> I will try it , how much time will it take for 35gb database ? is this
> method suggest able for a 35gb database ?

Very much depends on your server. I've had some that could copy that
much over in a few minutes, some that might take most of an hour. But,
generally speaking creating a db from a template is about as fast as
it gets.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2017-07-25 21:07 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-07-21 19:28 How to duplicate postgres 9.4 database srilinux <srilinux09@gmail.com>
2017-07-21 20:07 ` Igor Neyman <ineyman@perceptron.com>
2017-07-22 23:43   ` srilinux <srilinux09@gmail.com>
2017-07-25 21:07     ` Scott Marlowe <scott.marlowe@gmail.com>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox