Re: Methods to quickly spin up copies of an existing databases

From: Kevin Wilkinson <w(dot)kevin(dot)wilkinson(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Methods to quickly spin up copies of an existing databases
Date: 2019-03-01 19:57:30
Message-ID: d042d137-1888-6040-4cd7-e498941ea15e@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

if you are able/willing to use ZFS (rather than ext4, xfs, ...) to store
your database, then it might work for you. ZFS is copy-on-write so it
can very quickly clone a database.

kevin

On 3/1/2019 12:08 PM, Arjun Ranade wrote:
> I'm working on a project that requires on-demand creation of a fresh
> database as quick as possible (seconds). Essentially, this is a build
> server that will require a cloned instance of Postgres to run unit
> tests on.  So the pattern of use would be:
>
> * Build is triggered
> * New postgres instance is created and connection details are
> provided to build server
> * Build runs unit tests that connect to the database
> * Build completes, database is no longer needed and can be thrown away
>
> The "template" database will be approximately 50gb in size so my
> question is what is the fastest way to spin up new instances of this
> database?  I've thought of using "CREATE DATABASE WITH TEMPLATE..."
> but that takes too long. I've also thought about cloning the $PGDATA
> directory, changing the port number in postgresql.conf, and starting a
> new instance of postgres pointing to the cloned data directory.
>
> Both of these methods take longer than I'd like, so I'm wondering if
> anyone else has this use case and what methods they've used to solve this.
>
> Thanks,
> Arjun

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kenneth Marshall 2019-03-01 20:00:17 Re: Methods to quickly spin up copies of an existing databases
Previous Message Bill Haught 2019-03-01 19:11:32 Re: Future Non-server Windows support???