Skip site navigation (1) Skip section navigation (2)

Re: createdb Question

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: <operationsengineer1(at)yahoo(dot)com>
Cc: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: createdb Question
Date: 2005-11-16 01:33:17
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Nov 16, 2005, at 8:45 , <operationsengineer1(at)yahoo(dot)com> wrote:

> if i can create a db as a copy of an existing db, can
> someone point me to howto or give a quick, fictional
> example how to get this done?

existing db cluster with db foo:
pg_dump foo > foo-dump.sql

new db cluster:
createdb foo2
psql -d foo2 -f foo-dump.sql

If you have users and groups that you need to transfer as well,  
you'll want to look at pg_dumpall with the -g flag. You may want to  
edit the output of pg_dumpall by hand to only get the things you  
want. And you'll load the pg_dumpall output into the new db cluster  
(with psql) before loading foo-dump.sql.

Take a look at the pg_dump and pg_dumpall docs for more details.

Hope this helps.

Michael Glaesemann
grzm myrealbox com

In response to


pgsql-novice by date

Next:From: Emiliano AmilcarelliDate: 2005-11-16 14:09:09
Subject: plpython integer types
Previous:From: meDate: 2005-11-16 00:59:52
Subject: 8.1: autovacuum not doing its job?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group