Re: Fastest way to duplicate a quite large database

From: Louis Battuello <louis(dot)battuello(at)etasseo(dot)com>
To: Edson Richter <edsonrichter(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Fastest way to duplicate a quite large database
Date: 2016-04-12 15:03:34
Message-ID: B4335D14-F696-42CF-9FBB-69D1717D5C43@etasseo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On Apr 12, 2016, at 10:51 AM, Edson Richter <edsonrichter(at)hotmail(dot)com> wrote:
>
> Same machine, same cluster - just different database name.
>
> Atenciosamente,
>
> Edson Carlos Ericksson Richter
>
> Em 12/04/2016 11:46, John R Pierce escreveu:
>> On 4/12/2016 7:25 AM, Edson Richter wrote:
>>>
>>> I have a database "Customer" with about 60Gb of data.
>>> I know I can backup and restore, but this seems too slow.
>>>
>>> Is there any other option to duplicate this database as "CustomerTest" as fast as possible (even fastar than backup/restore) - better if in one operation (something like "copy database A to B")?
>>> I would like to run this everyday, overnight, with minimal impact to prepare a test environment based on production data.
>>
>>
>> copy to the same machine, or copy to a different test server? different answers.
>>
>>
>>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

Not sure how fast is “fast” for your system. You could try:

create database customer_test with template customer;

I’m able to duplicate a 20GB in a couple minutes with the above command.

Couple caveats:

1. No active connections to customer are allowed during the create.
2. You’ll likely have to recreate the search_path and reissue connect grants to the newly created database.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-04-12 15:04:16 Re: Fastest way to duplicate a quite large database
Previous Message Adrian Klaver 2016-04-12 15:01:03 Re: Freezing localtimestamp and other time function on some value