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 1jaxai-00014K-NZ for pgsql-general@arkaria.postgresql.org; Tue, 19 May 2020 08:27:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jaxah-0000xw-Lo for pgsql-general@arkaria.postgresql.org; Tue, 19 May 2020 08:27:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jaxah-0000wB-E0 for pgsql-general@lists.postgresql.org; Tue, 19 May 2020 08:27:11 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jaxaf-0001uO-82 for pgsql-general@postgresql.org; Tue, 19 May 2020 08:27:10 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 668C5ABE; Tue, 19 May 2020 11:27:07 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KtfHcLpZDxZs; Tue, 19 May 2020 11:27:05 +0300 (EEST) Received: from mail.hot.ee (hot-relayhost2.estpak.ee [213.180.2.80]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 2B2B816C3; Tue, 19 May 2020 11:27:05 +0300 (EEST) Received: from dell2 (66-63-196-88.sta.estpak.ee [88.196.63.66]) (Authenticated sender: kobruleht2) by HOT-Relayhost2.estpak.ee (Postfix) with ESMTPSA id 49R8BF5mnkz2VZ; Tue, 19 May 2020 11:27:00 +0300 (EEST) Message-ID: <0B5B726FEF194328AAFABFC6AF66838D@dell2> From: "Andrus" To: "Kyotaro Horiguchi" Cc: , References: <6D4B5482A2F645E6A7D4EF0BF098F3E0@dell2><5EB4D21935104DC19E271B490CD16BAA@dell2> <20200519.161443.2239326109074731181.horikyota.ntt@gmail.com> In-Reply-To: <20200519.161443.2239326109074731181.horikyota.ntt@gmail.com> Subject: Re: Hot and PITR backups in same server Date: Tue, 19 May 2020 11:26:51 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi! Thank you. >As Laurentz said, even if you set it to 5TB, no WAL files older than >the files needed by the last checkpoint don't remain. If you don't >need a hot-standby, you can use pg_receivewal to save WAL files on the >"standby" server. If you need the hot-standby, WAL files should be >archived. So pg_receivewal should running in parallel with hot standy server to receive wal files to separate directory. Will each wal file transferred two times in this case? One time by hot standby server and second time by pg_receivewal. Main server if priced by amount of bandwidth. How to receive each wal file only once ? This would allow to decrease network bandwidth and thus cost two times. pg_receivewal has compression option. Will this compress WAL files before transfer over network ? >If so, what you need seems to be pg_receivewal, not a full-fledged >server. For hot standby and PITR in same server the following steps are required: 1. Create base backup using pg_basebackup 2. Create copy of base backup for PITR 3. Start hot standby server using data directory created in p.1 4. Run pg_receiceval as background process to save wal files to backup created in p.2 If PITR is required, specify recovery time in base backup created in p.2 in postgresql.conf Start second postgresql server instance in port 5433 which uses this backup for recovery. Is this OK or should something changed? How to run pg_receivewal in background ? Is there some option which creates such service so will automatically restart if server is restarted ? How to allow main server to keep sufficient number of WAL segments ? Replication slot cannot used: if backup server stops replication_slot causes main server to fill disk space with untransferred WAL files. After that main server will also stop with "no space left on device" error. Or is there some option like to reserve some disk space or limit wal size so that main server can continue on backup server crash. Andrus.