X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 82E9BD1B385 for ; Wed, 21 Jul 2004 23:39:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67963-08 for ; Thu, 22 Jul 2004 02:39:18 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E38C1D1B37D for ; Wed, 21 Jul 2004 23:39:13 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6M2dFQd002111; Wed, 21 Jul 2004 22:39:15 -0400 (EDT) To: Mark Kirkwood Cc: Simon Riggs , pgsql-admin@postgresql.org Subject: Re: [HACKERS] Point in Time Recovery In-reply-to: <40FF1D88.30404@coretech.co.nz> References: <200407132242.i6DMgg612564@candle.pha.pa.us> <1089760416.17493.3327.camel@stromboli> <40F49AE9.2060805@familyhealth.com.au> <1089789682.17493.3890.camel@stromboli> <40FF1D88.30404@coretech.co.nz> Comments: In-reply-to Mark Kirkwood message dated "Thu, 22 Jul 2004 13:51:04 +1200" Date: Wed, 21 Jul 2004 22:39:15 -0400 Message-ID: <2110.1090463955@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/240 X-Sequence-Number: 14308 Mark Kirkwood writes: > Here is one for the 'idiot proof' category: > 1) initdb and set archive_command > 2) shutdown > 3) do a backup > 4) startup and run some transactions > 5) shutdown and remove PGDATA > 6) restore backup > 7) startup > Obviously this does not work as the backup is performed with the > database shutdown. Huh? It works fine. The bit you may be missing is that if you blow away $PGDATA including pg_xlog/, you won't be able to recover past whatever you have in your WAL archive area. The archive is certainly not going to include the current partially-filled WAL segment, and it might be missing a few earlier segments if the archival process isn't speedy. So you need to keep those recent segments in pg_xlog/ if you want to recover to current time or near-current time. I'm becoming more and more convinced that we should bite the bullet and move pg_xlog/ to someplace that is not under $PGDATA. It would just make things a whole lot more reliable, both for backup and to deal with scenarios like yours above. I tried to talk Bruce into this on the phone the other day, but he wouldn't bite. I still think it's a good idea though. It would (1) eliminate the problem that a tar backup of $PGDATA would restore stale copies of xlog segments, because the tar wouldn't include pg_xlog in the first place. (2) eliminate the problem that a naive "rm -rf $PGDATA" would blow away xlog segments that you still need. A possible compromise is that we should strongly suggest that pg_xlog be pushed out to another place and symlinked if you are going to use WAL archiving. That's already considered good practice for performance if you have a separate disk spindle to put WAL on. It'll just have to be good practive for WAL archiving too. regards, tom lane