X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 91A5FD1B195 for ; Tue, 13 Jul 2004 20:54:08 -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 33147-03 for ; Tue, 13 Jul 2004 23:54:08 +0000 (GMT) Received: from cmailm3.svr.pol.co.uk (cmailm3.svr.pol.co.uk [195.92.193.19]) by svr1.postgresql.org (Postfix) with ESMTP id 489C1D1B1A0 for ; Tue, 13 Jul 2004 20:54:04 -0300 (ADT) Received: from modem-89.lynx.dialup.pol.co.uk ([217.135.192.89] helo=[192.168.0.100]) by cmailm3.svr.pol.co.uk with esmtp (Exim 4.14) id 1BkX66-0001Rm-7k; Wed, 14 Jul 2004 00:54:06 +0100 Subject: Re: Point in Time Recovery From: Simon Riggs To: Tom Lane Cc: Bruce Momjian , pgsql-hackers@postgresql.org In-Reply-To: <20205.1089761301@sss.pgh.pa.us> References: <200407132301.i6DN1fb16205@candle.pha.pa.us> <20205.1089761301@sss.pgh.pa.us> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1089762845.17493.3417.camel@stromboli> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) Date: Wed, 14 Jul 2004 00:54:05 +0100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/737 X-Sequence-Number: 56298 On Wed, 2004-07-14 at 00:28, Tom Lane wrote: > Bruce Momjian writes: > > OK, but procedurally, how do you correlate the start/stop time of the > > tar backup with the WAL numeric file names? > > Ideally the procedure for making a backup would go something like: > > 1. Inquire of the server its current time and the WAL position of the > most recent checkpoint record (which is what you really need). > > 2. Make the backup. > > 3. Inquire of the server its current time and the current end-of-WAL > position. > > 4. Record items 1 and 3 along with the backup itself. > > I think the current theory was you could fake #1 by copying pg_control > before everything else, but this doesn't really help for step #3, so > it would probably be better to add some server functions to get this > info. > err...I think at this point we should review the PITR patch.... The recovery mechanism doesn't rely upon you knowing 1 or 3. The recovery reads pg_control (from the backup) and then attempts to de-archive the appropriate xlog segment file and then starts rollforward from there. Effectively, restore assumes it has access to an infinite timeline of logs....which clearly isn't the case, but its up to *you* to check that you have the logs that go with the backups. (Or put another way, if this sounds hard, buy some software that administers the procedure for you). That's the mechanism that allows "infinite recovery". In brief, the code path is as identical as possible to the current crash recovery situation...archive recovery restores the files from archive when they are needed, just as if they had always been in pg_xlog, in a way that ensures pg_xlog never runs out of space. Recovery ends when: it reaches the recovery target you specified, or it runs out of xlogs (first it runs out of archived xlogs, then tries to find a more recent local copy if there is one). I think the current theory was you could fake #1 by copying pg_control > before everything else, but this doesn't really help for step #3, so > it would probably be better to add some server functions to get this > info. Not sure what you mean by "fake".... Best Regards, Simon Riggs