Re: Restoring a database - Mailing list pgsql-general

From Jeff Frost
Subject Re: Restoring a database
Date
Msg-id 48F66019.5080909@frostconsultingllc.com
Whole thread Raw
In response to Restoring a database  ("Chris Henderson" <henders254@gmail.com>)
Responses Re: Restoring a database  (Jeff Frost <jeff@frostconsultingllc.com>)
List pgsql-general
Chris Henderson wrote:
> I backup all my databases by using pg_dumpall - pg_dumpall >
> /tmp/postgres.backup.`hostname`. It should backup four DBs: analyze,
> postgres,  template0 and template1
> I guess this backs up the schemas as well.
>
> Now I want to restore one of the databases and schema from this backup
> dump file onto a different server. The databases is call "analyze".
> Does anyone know how to do that with pg_restore? Thanks.
>
Chris,

pg_restore is used to restore backups that were saved in the custom
format by pg_dump (option -Fc).  You don't need pg_restore to restore a
pg_dumpall archive.  If you look at the backup file, you'll find that
it's just straight SQL.  If you want to restore a particular database
out of it and not all of them, then you will need to edit the sql file
to include only what you want to restore.  Then you simply pass it
through psql like so:

psql -f /tmp/postgres.backup.`hostname` postgres

Hint: the above will require that the CREATE DATABASE and \connect
commands for the database you want to restore are still in the file.

--
Jeff Frost, Owner     <jeff@frostconsultingllc.com>
Frost Consulting, LLC     http://www.frostconsultingllc.com/
Phone: 916-647-6411    FAX: 916-405-4032


pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: Restoring a database
Next
From: Jeff Frost
Date:
Subject: Re: Restoring a database