Mirroring a DB (was Re: [GENERAL] \d shows all my tables twice) - Mailing list pgsql-general

From Karl DeBisschop
Subject Mirroring a DB (was Re: [GENERAL] \d shows all my tables twice)
Date
Msg-id 199912112320.SAA12300@h00a0cc3b7988.ne.mediaone.net
Whole thread Raw
List pgsql-general
>  > By the way, I know about using pg_dump to backup the database and I do
>  > that.  Is there a good way to maintain a second identical copy of the
>  > database on another machine?  Will simply copying the dump over and
>  > restoring it with psql do the trick?  Would I need to delete an old copy
>  > of the same database first?  We have a somewhat slow Internet connection
>  > to our Linux system's location and it would be nice to have an alternate
>  > site with the same data.
>
>  We sometimes do:
>
>   pg_dump -o -h <live> <table> | psql -h <mirror> <table>
>
>  (Note that you will probably want -z as well if pre-6.5)
>
>  This generally works, but has a habit recreating the views as actual
>  tables.  Often you can live with this, and there may be a simple way
>  to prevent it.  I just haven't found one yet.

Based on notes from the PostgreSQL development team and subsequent
testing on our machines, it appears this issue was fixed by either
6.5.2 or 6.5.3 - so the pipe above should work reliably now, assuming
your view was created using a DBMS version 6.5.3 (or maybe 6.5.2 will
do as well).  To avoid needing to destory/create the DB, use:

    pg_dump -c -o -h <live> <database> | psql -h <mirror> <database>

Note the addition of the -c option and the correction of my typo --
where I meant <database> I said <table> earlier.

Hope this helps.

Karl

pgsql-general by date:

Previous
From: Karl DeBisschop
Date:
Subject: Re: Mirroring a DB
Next
From: Rick Dearman
Date:
Subject: Getting lists of databases