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 1nRl3w-0001YX-EJ for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Mar 2022 01:24:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nRl3v-0003Xw-4Y for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Mar 2022 01:24:23 +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 1nRl3u-0003Xm-En for pgsql-hackers@lists.postgresql.org; Wed, 09 Mar 2022 01:24:22 +0000 Received: from anastigmatix.net ([68.171.219.55]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRl3r-0005W0-Va for pgsql-hackers@lists.postgresql.org; Wed, 09 Mar 2022 01:24:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pagnlB9HjmzEd9HdQ9lDF7yGLfeoGEmO8SdaW1bMoGQ=; b=k9nCDrDzjgn5cIohnprz2t6Igo 28o/2obvfrfDdhkSCaFPlA31lzXP6lG/kbXQvO2iU8g7nzABJqEgZZpFL2hvMd3G209w7nehtuVZv J72s42XEEyIiHkt/66KRLpa0+HM7sc3fS4h1zI9NzR1eJlAz5fSOhCJGAJJwMKarmn2J7156YvhRR T7Ts89KVE1I0SgQUAOZfKDwpBGJyGjE2cvtqapUXzph23MT4Dk/vWB6k754E54Zx2ZO5fA5Ob/Xxb v+Ux2aM6g5dKBnNGRZ8yeHaxByFGMe1TqsWRdsu8nVxjEqcsK9DXenNAVINGH5wdD5zDxHlWwqjyA JN35iP8A==; Received: from 50-102-16-206.prtg.in.frontiernet.net ([50.102.16.206]:53352) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nRl3n-000zYd-4j; Tue, 08 Mar 2022 20:24:16 -0500 Subject: Re: Postgres restart in the middle of exclusive backup and the presence of backup_label file To: Nathan Bossart , David Steele References: <20220301173208.GB1031413@nathanxps13> <1f685b3a-7ec2-825e-bb2b-d87d78ad5bd9@pgmasters.net> <621E6C2E.2050801@anastigmatix.net> <20220301191441.GW10577@tamriel.snowman.net> <621E7A5C.1030203@anastigmatix.net> <20220301200523.GX10577@tamriel.snowman.net> <20220302010302.GA1182956@nathanxps13> <621FC447.90502@anastigmatix.net> <20220308200107.GA85558@nathanxps13> <20220308221253.GA169440@nathanxps13> Cc: Stephen Frost , pgsql-hackers@lists.postgresql.org From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <622801BD.9020605@anastigmatix.net> Date: Tue, 8 Mar 2022 20:24:13 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <20220308221253.GA169440@nathanxps13> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 03/08/22 17:12, Nathan Bossart wrote: > I spent some time trying to come up with a workable script to replace the > existing one. I think the main problem is that you need to write out both > the backup label file and the tablespace map file, but I didn't find an > easy way to write the different output columns of pg_backup_stop() to > separate files via psql. Something like this might work: SELECT * FROM pg_backup_stop(true) \gset \out /tmp/backup_label \qecho :labelfile \out /tmp/tablespace_map \qecho :spcmapfile \out \! ... tar command adding /tmp/{backup_label,tablespace_map} to the tarball I notice the \qecho adds a final newline (and so if :spcmapfile is empty, a file containing a single newline is made). In a quick test with a bogus restore_command, I did not see any error messages specific to the format of the backup_label or tablespace_map files, so maybe the final newline isn't a problem. Assuming the newline isn't a problem, that might be simple enough to use in an example, and maybe it's not a bad thing that it highlights a few psql capabilities the reader might not have stumbled on before. Or, maybe it is just too confusing to bother. While agreeing that pg_basebackup is the production-ready thing that does it all for you (with tests for likely errors and so on), I think there is also some value in a dead-simple example that concretely shows you what "it" is, what the basic steps are that happen beneath pg_basebackup's chrome. If the added newline is a problem, I haven't thought of a way to exclude it that doesn't take the example out of the realm of dead-simple. Regards, -Chap