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 1gAFP1-0002Ak-12 for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 14:23:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAFOy-0003Wo-RK for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 14:23:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAFOy-0003Wf-J4 for pgsql-general@lists.postgresql.org; Wed, 10 Oct 2018 14:23:52 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gAFOr-00073C-U9 for pgsql-general@postgresql.org; Wed, 10 Oct 2018 14:23:52 +0000 Received: by mail-qt1-x82f.google.com with SMTP id o17-v6so5840813qtr.1 for ; Wed, 10 Oct 2018 07:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:openpgp:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4LAl1HP4rLBm2bPK981Hd6+QxlcuSmsLEwIUdM+QaoE=; b=wVBnx5oYXwhKem6fWdtZIzgR5cjO+eEMhcbjwUOmryjJ8YL6uqIBLredoz8KLmzbNV miBiF5YU6J/OjrmrO0okT0vwU/9869Eig51gymfuOoYG1cawBpfiC288xN//NNx1eCne D2n22ZmiL1dfbYNzyHy7Wr62nxgXVYqSeb8QWPXQMCaquNCI5GaKBax8ci4loCzYJqS7 u8o5DXn9YJEyxYV6G2WdxGG1YcRrloixd/nyBXTKNIJ3aTq3JMLmu/uarfh/FoYG4zz7 EVVi/wKYOwJ2XqBkwgPJXORMYeSvmMDQtzZqqqB01JGylGukmmtxqFoUSZhlJhztIPL3 3rVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4LAl1HP4rLBm2bPK981Hd6+QxlcuSmsLEwIUdM+QaoE=; b=uZk20ponpzz+2VN5eMgWWq7Dh++zHFVzbBrYR1YDx2cFjvIlOgO1VxQPCBVmSNg3AF 3NEeiiqWKTmWoRujJ3UtwLWixiZT37aZZLDarhB3Ig/RConqRD1fWdH+jcbjbuc7xLIO HVZVu3R3uBw/jYlZ4NIcX1MLkOCbzCXK4r0OfTiqfTpaRzLQFbzbE221r+bjtm7Zlgjq GEhTCrzoEYiCWZKJfU/DwSW5YL9+KiOlQTjV6BKod4XMJvsxJVoXhPN7lzbxwJRArSkJ XiSk2gY6dbGGRb2YtQfj6OMacUkRBUBx8JgLFR8/UWNppYb+lomaPkiKmvQbZnxuPYIe mxEQ== X-Gm-Message-State: ABuFfohEhGcwBvCICT/AItXEDZXvg3P4E5ZN8L8UZQ2/P5DJNF7eZDgv AAJP0jn02bXsHrjD0dMDHUWaP0ueqcPlPrfraGARcmllDrnbHsOiFQC09QKVUHN8on5WE9Z6t/I 4w3zDP9iYde0ZqqQOUtpKzNaWAggRHyEgCImq8ecX16DN4+4cdxkG5K00R/WnQNKI0HIIyanScC QInFdRTgRlI02NQg== X-Google-Smtp-Source: ACcGV60J3kxGf7XUlsi70GCE/BCvmN6XZwr/9czNlcdUIPJE5Y+2jZ5Z5tzWfAZczdnrO+M1sPaw8Q== X-Received: by 2002:a0c:df86:: with SMTP id w6mr2219930qvl.33.1539181423841; Wed, 10 Oct 2018 07:23:43 -0700 (PDT) Received: from alderaan.marques ([181.95.22.137]) by smtp.googlemail.com with ESMTPSA id j6-v6sm5704788qtb.25.2018.10.10.07.23.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 07:23:43 -0700 (PDT) Subject: Re: how to cleanup archive based on datetime To: magodo , Postgres general References: From: Martin Marques Openpgp: preference=signencrypt Message-ID: <6d0bf038-d4ad-033a-38bd-94c01e9e4b4d@2ndquadrant.com> Date: Wed, 10 Oct 2018 11:23:40 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: es-AR Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk El 10/10/18 a las 04:00, magodo escribió: > > 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? > > 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? Don't do that manually. Install `barman` and let it take care of removing old WALs which are not needed anyore. Regards, -- Martín Marqués http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services