Thread: Read only postgres server

Read only postgres server

From
EvilJonny
Date:
Hello,

Is it possible to start the postgres server up in a read only mode
rather than doing specific user permissions.

The reason I ask is I am migrating from one platform to another (with
different versions of postgres), I've done a pg_dump and imported that
on the new platform, I have a script which copies all new rows from the
old platform to the new platform.

What I want to do is stop all writes to the old platform, copy all the
new rows using the script mentioned previously and then change the
clients to write to the new database. It's critically important for me
to have the databases in sync with all ids in all tables matching and
not to lose any data.

To this end it's worth nothing that clients that fail to write will try
again every five minutes so any failed writes in the mean time are
effectively queued and will be written to the new platform once it is on.

I could revoke the user privileges but I want to be able to very quickly
revert to the old platform with as simple of a procedure as possible if
anything goes wrong during the transfer, as such I would prefer not to
alter any of the data in the database. If it's not possible to start up
in read only globally across the server then I will just do this but it
will require a more complex rollback plan.

Thanks,

Jonathan

Re: Read only postgres server

From
Jasen Betts
Date:
On 2010-04-02, EvilJonny <eviljonny@eviljonnys.com> wrote:
> Hello,
>
> Is it possible to start the postgres server up in a read only mode
> rather than doing specific user permissions.
>
> The reason I ask is I am migrating from one platform to another (with
> different versions of postgres), I've done a pg_dump and imported that
> on the new platform, I have a script which copies all new rows from the
> old platform to the new platform.
>
> What I want to do is stop all writes to the old platform, copy all the
> new rows using the script mentioned previously and then change the
> clients to write to the new database. It's critically important for me
> to have the databases in sync with all ids in all tables matching and
> not to lose any data.
>
> To this end it's worth nothing that clients that fail to write will try
> again every five minutes so any failed writes in the mean time are
> effectively queued and will be written to the new platform once it is on.
>
> I could revoke the user privileges but I want to be able to very quickly
> revert to the old platform with as simple of a procedure as possible if
> anything goes wrong during the transfer, as such I would prefer not to
> alter any of the data in the database. If it's not possible to start up
> in read only globally across the server then I will just do this but it
> will require a more complex rollback plan.

revoking permissions seems good to me,
creat two scripts one to revoke and the other to grant,
if anything bad happens run the grant script.

hint:   pg_dump --schema-only DATABASE_NAME | grep GRANT