Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jObZa-0007nh-U2 for pgsql-general@arkaria.postgresql.org; Wed, 15 Apr 2020 06:30:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jObZZ-0002QC-2v for pgsql-general@arkaria.postgresql.org; Wed, 15 Apr 2020 06:30:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jObZY-0002N4-Lt for pgsql-general@lists.postgresql.org; Wed, 15 Apr 2020 06:30:56 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jObZV-0008Qg-Pe for pgsql-general@lists.postgresql.org; Wed, 15 Apr 2020 06:30:55 +0000 Received: by mail-wm1-x342.google.com with SMTP id e26so15986088wmk.5 for ; Tue, 14 Apr 2020 23:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=T0fJQAgn1hKeBfhoIRp7lgRY7WBB6VZBzawbtggUgR4=; b=Dwal39xenA0haPSoRK94mbcplityd0qbueteIBH0onv//YLyKsdpmdfUAADNQRkpcu rhMsp15aKgBp6XOAUh8tiGj0LJdjoj5XBfyTA1o4jUfHz2V7XmxFLkfh9vWLN3I06tJL zqp0XINP48rbOp4xVzcVhgvGLnAGQYDIhkntw2YKDYDPfYvIA6nDE/7Fr5KjkLpctoX1 zoIM9DQSGazUJoh04+WtHR0PDg1/+ytNHlF68JxBjRqcOR4hK/JGxKWiSvwJ0Tdzg9gT 0CLoHmZzhYkbDY2REN4IPB3G2K5E4AO6PAPyID+TDphovgFbt9nka/6RNDhA1QWcQ9qa +38A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=T0fJQAgn1hKeBfhoIRp7lgRY7WBB6VZBzawbtggUgR4=; b=lr0w5xhLvlTDTCiwMt9ZMb2JDP9RFQhVhPV3P5NBOM69dKpKMPlVpE3wW9jBdTxEIX 15yZRaCXgB6DLM58pc/y9fhOwf0s/Jxd6H845UiEdmkVHJTddIs8H7yBqrOtkcK+lghY rRGPMaq+k7eGEd/JWyjKMUJUoiDi2KCLtmw7GTaTF6o3Ps7IfG0LBaGvucJdeK5WGerk TTm3x2Rxvu5S0H2uxBRMdD1ch/tvy+yPKbtZ6YJv2z3WkOlDh0SbMUlsskKs8Jt62VsK lzdpJBTVfMApekhY/Gf5EoO3qxxanYKq2KLKCKDC3+4RybQHWJy3gLH6shDwzIbYUUBl osOA== X-Gm-Message-State: AGi0PubsuJa+Jv/d89thv6UEPafergD2Cm0af7YOlIwHUDgDOSqNIlI4 eEORzx09uXmXkqb5i/li+NvS7bo1DYU= X-Google-Smtp-Source: APiQypLe6werqo8Pyf6/0DqxmdeUDl0Wh5kkLBsQ51GW3fn6bi81px/u5E7VEqu3s7ihIegix1KFYg== X-Received: by 2002:a1c:7706:: with SMTP id t6mr3522425wmi.110.1586932251113; Tue, 14 Apr 2020 23:30:51 -0700 (PDT) Received: from dynamic-elilxk735ke74c2re-pd01.res.v6.highway.a1.net (dynamic-elilxk735ke74c2re-pd01.res.v6.highway.a1.net. [2001:871:60:19aa:aa2e:92c5:809a:78fa]) by smtp.gmail.com with ESMTPSA id k9sm22983927wrd.17.2020.04.14.23.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 23:30:50 -0700 (PDT) Message-ID: <281079d27fd4b21232e0f40fa6e73c277b74b246.camel@cybertec.at> Subject: Re: pg_basebackup && long time storage of wal_archive/ content From: Laurenz Albe To: Matthias Apitz , pgsql-general@lists.postgresql.org Date: Wed, 15 Apr 2020 08:30:49 +0200 In-Reply-To: <20200415061628.GA25565@sh4-5.1blu.de> References: <20200414150022.GA4613@sh4-5.1blu.de> <2fc2a90b-ab18-fd0c-c6ee-f5895471a8b1@aklaver.com> <20200415061628.GA25565@sh4-5.1blu.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 2020-04-15 at 08:16 +0200, Matthias Apitz wrote: > > > The run (as user 'postgres') on the server of the cmd: > > > > > > pg_basebackup -U ${DBSUSER} -Ft -z -D /data/postgresql11/backup-wal_archive-20200414-1/ > > > > > > produces correctly the following situtation on the server: > > > > > > srap32dxr1:/data/postgresql11 # ls -ltrh backup-20200414-1 > > > total 1.7G > > > -rw------- 1 postgres postgres 1.7G Apr 14 16:20 base.tar.gz > > > -rw------- 1 postgres postgres 17K Apr 14 16:20 pg_wal.tar.gz > > > srap32dxr1:/data/postgresql11 # ls -ltrh data/pg_wal > > > total 81M > > > -rw------- 1 postgres postgres 16M Apr 14 15:11 000000010000000C0000009F > > > -rw------- 1 postgres postgres 16M Apr 14 15:20 000000010000000C000000A0 > > > -rw------- 1 postgres postgres 16M Apr 14 16:10 000000010000000C000000A1 > > > -rw------- 1 postgres postgres 16M Apr 14 16:20 000000010000000C000000A2 > > > -rw------- 1 postgres postgres 342 Apr 14 16:20 000000010000000C0000009D.00000028.backup > > > drwx------ 2 postgres postgres 36K Apr 14 16:25 archive_status > > > -rw------- 1 postgres postgres 16M Apr 14 16:50 000000010000000C0000009E > > > srap32dxr1:/data/postgresql11 # ls -ltrh wal_archive/ > > > total 49M > > > -rw------- 1 postgres postgres 16M Apr 14 15:20 000000010000000C0000009B > > > -rw------- 1 postgres postgres 16M Apr 14 16:10 000000010000000C0000009C > > > -rw------- 1 postgres postgres 16M Apr 14 16:20 000000010000000C0000009D > > > -rw------- 1 postgres postgres 342 Apr 14 16:20 000000010000000C0000009D.00000028.backup > > > > > > The content of the dir wal_archive/ is growing and growing over the > > > time. > > > > > > The pg_wal.tar.gz contains: > > > > > > srap32dxr1:/data/postgresql11 # tar tzf backup-20200414-1/pg_wal.tar.gz > > > 000000010000000C0000009D > > > > > > i..e. the files 000000010000000C0000009B ... 000000010000000C0000009D > > > could be removed in wal_archive/ > > > > > > Correct? Or how is the long time storage of this dir? The best you can do is to use "pg_archivecleanup" with one of these *.backup files. If you run pg_archivecleanup wal_archive 000000010000000C0000009D.00000028.backup it will delete all WAL archives older than that backup. So that backup can still be restored, and you can recover to any later point in time, but all older WAL is removed. > > pg_basebackup is a point in time backup tool. > > Thanks for the answer. What do you mean by 'point in time backup tool'? I think he meant "online file system-level backup tool" - you need point-in-time-recovery to restore such a backup. > And, coming back to my question, can older WAL in wal_archive/ be > removed without any risks if the daily > > pg_wal.tar.gz > base.tar.gz > > are moved to a safe place? Yes, because "-X stream" is the default for "pg_basebackup". "pg_wal.tar.gz" will contain all the WAL necessary to recover the backup, so if you unpack its contents into the "pg_wal" subdirectory of the unpacked base backup, you can simply start the server, and it will recover to the end of the backup. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com