Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9FCA2633CE2 for ; Mon, 22 Mar 2010 14:58:21 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 12991-03-5 for ; Mon, 22 Mar 2010 17:58:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og123.obsmtp.com (exprod7og123.obsmtp.com [64.18.2.24]) by mail.postgresql.org (Postfix) with SMTP id 945AE6340CD for ; Mon, 22 Mar 2010 14:57:58 -0300 (ADT) Received: from source ([74.125.82.48]) by exprod7ob123.postini.com ([64.18.6.12]) with SMTP ID DSNKS6evpVO5OlUF8PK8sZ7L+LlaCrQRuObt@postini.com; Mon, 22 Mar 2010 10:57:58 PDT Received: by wwc33 with SMTP id 33so3277436wwc.35 for ; Mon, 22 Mar 2010 10:57:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.162.204 with SMTP id y54mr2933516wek.224.1269280675793; Mon, 22 Mar 2010 10:57:55 -0700 (PDT) In-Reply-To: <27984540.post@talk.nabble.com> References: <27984540.post@talk.nabble.com> Date: Mon, 22 Mar 2010 13:57:55 -0400 Message-ID: Subject: Re: Backup&Restore Postgres DB From: Scott Mead To: blast Cc: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=0016367d6d92cd0cca0482676fe6 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.464 tagged_above=-10 required=5 tests=AWL=0.134, BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201003/153 X-Sequence-Number: 33952 --0016367d6d92cd0cca0482676fe6 Content-Type: text/plain; charset=ISO-8859-1 Lots there, let's break it down individually: On Mon, Mar 22, 2010 at 6:38 AM, blast wrote: > > Hi all, > > I need to backup and restore a DB. > In this particular case the data in the database is not important (strange > hum...) but only the schema to put new data... > > I m thinking use the pg_dump: > > pg_dump -c -C -s schema > file.out > Almost.... -s says "only dump the structure of the database" If you want to dump a specific named schema inside the database, you'd use: -n So, what you end up with is: pg_dump -c -C -s -n [schema] [database] > file.out > > With this i have in file.out the schema, correct? > Yes > > So, to restore the db from scratch, for example to a new system, what > should > i do? > psql -d [database] -f file.out > it automatically creates all users, rolls, permissions etc?How? > To create users, you need to dump them from the source db first (pg_dump doesn't do users)... so pg_dumpall -g > users.sql psql -d [database] -f users.sql do this BEFORE you do the restore of your objects and all your permissions etc... will be set. > > What is the best way of doing it? > > Good luck! > > Many thanks > > -- > View this message in context: > http://old.nabble.com/Backup-Restore-Postgres-DB-tp27984540p27984540.html > Sent from the PostgreSQL - admin mailing list archive at Nabble.com. > > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin > --0016367d6d92cd0cca0482676fe6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Lots there, let's break it down individually:


On Mon, Mar 22, 2010 at 6:38 AM, blast <carlosd2002@hotmail= .com> wrote:

Hi all,

I need to backup and restore a DB.
In this particular case the data in the database is not important (strange<= br> hum...) but only the schema to put new data...

I m thinking use the pg_dump:

pg_dump -c -C -s schema > file.out

A= lmost....=A0

=A0=A0 -s says "only dump the st= ructure of the database"
=A0=A0 If you want to dump a specif= ic named schema inside the database, you'd use:

=A0=A0 -n <schema>

So, w= hat you end up with is:

=A0pg_dump -c -C -s -n [sc= hema] [database] > file.out
=A0

With this i have in file.out the schema, correct?

=
Yes
=A0

So, to restore the db from scratch, for example to a new system, what shoul= d
i do?

psql -d [database] -f file.out=A0=
=A0
it automatically creates all users, rolls, permissions etc?How?

To create users, you need to dump them from the so= urce db first (pg_dump doesn't do users)...=A0
so

pg_dumpall -g > users.sql

psql -= d [database] -f users.sql=A0

do this BEFORE you do= the restore of your objects and all your permissions etc... will be set.
=A0

What is the best way of doing it?



=A0Good luck!=A0
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex;">
Many thanks

--
View this message in context: http://old.nabbl= e.com/Backup-Restore-Postgres-DB-tp27984540p27984540.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.


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

--0016367d6d92cd0cca0482676fe6--