pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Mead <scott.lists@enterprisedb.com>
To: blast <carlosd2002@hotmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Backup&Restore Postgres DB
Date: Mon, 22 Mar 2010 13:57:55 -0400
Message-ID: <d3ab2ec81003221057g199f44f5qa37a31b31bb87e79@mail.gmail.com> (raw)
In-Reply-To: <27984540.post@talk.nabble.com>
References: <27984540.post@talk.nabble.com>

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
> 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 <schema>

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
>

view thread (3+ messages)  latest in thread

Message-ID: <d3ab2ec81003221057g199f44f5qa37a31b31bb87e79@mail.gmail.com>
Permalink:  ../d3ab2ec81003221057g199f44f5qa37a31b31bb87e79@mail.gmail.com/
Also on:    postgresql.org/message-id/d3ab2ec81003221057g199f44f5qa37a31b31bb87e79@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: scott.lists@enterprisedb.com, carlosd2002@hotmail.com
  Subject: Re: Backup&Restore Postgres DB
  In-Reply-To: <d3ab2ec81003221057g199f44f5qa37a31b31bb87e79@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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