Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAFGG-0001az-DM for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 14:14:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAFGE-0005bp-Eq for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 14:14:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAFGE-0005bf-2V for pgsql-general@lists.postgresql.org; Wed, 10 Oct 2018 14:14:50 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAFG7-0006yU-1I for pgsql-general@postgresql.org; Wed, 10 Oct 2018 14:14:48 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 37FFC22001; Wed, 10 Oct 2018 10:14:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 10 Oct 2018 10:14:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=J flKNx30iT8rR3JDGrx/F7yyBv0KsWPyYwwg9v5hHXo=; b=i6kVXn7M6EI1tckrN ysib3/X5UHiOoCvbJ7aPxhUrmyL2LRrAgGyBRl91FoBfbd3H1/Wo96RKOXlGz+NS do8VE/ZUKNzLMfzKVlNp9RJHlblB+VMfJoMR1x8TMGzkSP1XQt/WaTAC+rFjhUkC OHBtNffQG+IMMHt3tsfJRXj0R98TwQWbJkNOdjz9EmUrrLQ+cTHiuu1+52mfXl5p Cys3DrYz86uhjwdxTdmybUz7ZJeVSYOl6GjaEiSoRiLyY3lENZ1GfWtZ+lzkCdFx gJq5//29uEd9Xav0icV0syi0HN7QyrfbUmos7zuoCnMDn+DlR3lzO99GpoyGoI6W 93H5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=JflKNx30iT8rR3JDGrx/F7yyBv0KsWPyYwwg9v5hH Xo=; b=XH235YLwhnOYOujSx8L8pR46TKt2CbZHN+xCMu650fbMP2sRJ2GqNIalZ d8JqzVqCk1tC07Mhna1sGe+AgCg+8Tuy6H7fZkrT9db1PJhp1cl/vFJM0XWtULu3 STLdtMlBd56J9YVrMJOo51DSWpj8NZSAdVftLjk0xyzih6haQW86Kyl9Vn5GM2Jf S8JkN7+EIfhIi7jiGkldG+kom0/GYZh9sEDPkCLlRPAS55a6+zSTQ6rNCXHWdp5f E5WonAtxx9s+0ofqkJmPshlXNzlJq0yJdfGvuDXfTo8KJcLEMmkpibiGsFgUeqRU SxUQPZ2LhDoDwmGIL7ZxX4FwRIUVQ== X-ME-Sender: X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id DDDE5E447F; Wed, 10 Oct 2018 10:14:40 -0400 (EDT) Subject: Re: how to cleanup archive based on datetime To: magodo , Postgres general References: From: Adrian Klaver Message-ID: <45fd9e0f-9023-3a6a-7e3e-9da41fa006f9@aklaver.com> Date: Wed, 10 Oct 2018 07:14:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/10/18 12:00 AM, magodo wrote: > > Hello, > > I know there is a tool `pg_archivecleanup`, but it only accepts wal > filename. What if I want to clean up all archived wal before a > specified datetime? That is dangerous, given that a WAL is important not based on its age but on whether it's content is still needed. It would help to know what it is you are trying to achieve? > > Though I could check the ctime fo each wal and figure out which to > remove, but it looks like not a elegent way to do this. > > Also I tried to parse each wal and compare with the specified datetime > in a binary-search way, but it is based on the fact that every COMMIT > time in wal is sequential, but it looks like not the case.. > > Hence I wonder what is the best practice for this task? > > Thank you in advance! > --- > Magodo > > > > -- Adrian Klaver adrian.klaver@aklaver.com