Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 144C3632AD8 for ; Sun, 6 Jun 2010 20:23:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 42805-02 for ; Sun, 6 Jun 2010 23:23:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from imail.internode.com.au (exchht01-ext.internode.com.au [203.26.95.185]) by mail.postgresql.org (Postfix) with ESMTP id A7618632367 for ; Sun, 6 Jun 2010 20:23:10 -0300 (ADT) Received: from EXCHMAIL.staff.internode.com.au ([169.254.1.229]) by exchht01.staff.internode.com.au ([fe80::193f:3ff6:d38f:74dc%12]) with mapi; Mon, 7 Jun 2010 08:53:05 +0930 From: Samuel Stearns To: "gnanam@zoniac.com" CC: "pgsql-admin@postgresql.org" Date: Mon, 7 Jun 2010 08:53:03 +0930 Subject: Re: PITR Recovery Question Thread-Topic: [ADMIN] PITR Recovery Question Thread-Index: AcsFdaca3hbFW2CVRFC5TimlTUHTUQAWVdaw Message-ID: <68B59BEDCD36854AADBDF17E91B2937A01A5937796@EXCHMAIL.staff.internode.com.au> References: <001201cb0321$df429d40$9dc7d7c0$@com> <00ca01cb03dc$a9ffe780$fdffb680$@com> <00cc01cb047d$82079830$8616c890$@com> <7B83DD06-04B8-4BE5-8573-3CDD48568F1D@phlo.org> In-Reply-To: <7B83DD06-04B8-4BE5-8573-3CDD48568F1D@phlo.org> Accept-Language: en-US, en-AU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, en-AU Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.489 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_ILLEGAL_IP=3.399, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: * X-Archive-Number: 201006/62 X-Sequence-Number: 34840 Here's a script to make your backup and rsync it to a remote destination: #!/bin/bash echo "checkpoint" echo "CHECKPOINT;" | /local/pkg/bin/psql template1 echo "start backup" echo "SELECT pg_start_backup('cisoradr:/cis/pgsql/katana7/backup');" | /loc= al/pkg/bin/psql template1 echo "rsync" /local/pkg/bin/rsync --delete -azxH /local/app/postgres/data pgsql@cisoradr= -ext:/cis/pgsql/katana7/backup/. echo "Stop backup" echo "SELECT pg_stop_backup();" | /local/pkg/bin/psql template1 Sam -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql= .org] On Behalf Of Florian Pflug Sent: Sunday, 6 June 2010 10:11 PM To: gnanam@zoniac.com Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] PITR Recovery Question On Jun 5, 2010, at 9:05 , Gnanakumar wrote: > Thanks for your valuable suggestion and a detailed step on common way to = use > PITR. Things are very clear now except that I've some other question in > connection to this. >=20 >> The correct way to clean out pg_xlog therefore is to either disable WAL = archiving, or to make sure your archive_command succeeds eventually. >=20 > Probably I would go with the 2nd option, that is allowing archive command= to > run successfully until things are completely clear. >=20 > But this question is for my understanding: In case if I decide to go wit= h > 1st option, that is disable WAL archiving for a while, will it completely > clean out files from pg_xlog/ and pg_xlog/archive_status/ directories, so > that I can start the PITR by taking base backup by enabling WAL archiving > later? If you disable WAL archiving by setting archive_command to 'true', it'll su= rely clean out the files, since postgresql will actually believe it archive= d them successfully. I not sure what happens if you set archive_command to = '' - that might disable the archiving process completely, and hence prevent= the cleanup. >> A common way to use PITR is the following. >=20 >> 4) You remove all WAL segments that predate the remaining base backups. = For that, you find the backup history file in the archive directory that co= rresponds to the oldest remaining base backup and then remove all WAL segme= nts whose name is numerically smaller than the from that backup h= istory file. Keeping older WAL segments buys you nothing - WAL files withou= t a base backup that *predates* them are worthless. >=20 > Can you share with me any automated shell script that takes care of this > removal automatically? Or can you share any systematic way (steps) of do= ing > things if I want to do this manually? Sorry, I don't have a script for this at hand. But a quick search through t= he pgsql-admin archive brings up this post, which contains such a script. http://archives.postgresql.org/pgsql-admin/2006-03/msg00337.php best regards, Florian Pflug --=20 Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin