Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j0A8d-0002Gn-T7 for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Feb 2020 20:22:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j0A8c-00017E-FX for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Feb 2020 20:22:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j0A8c-00016c-2J for pgsql-hackers@lists.postgresql.org; Fri, 07 Feb 2020 20:22:06 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j0A8V-0000MV-Fb for pgsql-hackers@lists.postgresql.org; Fri, 07 Feb 2020 20:22:04 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id BE23F21B34; Fri, 7 Feb 2020 15:21:58 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 07 Feb 2020 15:21:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=VORwiH2LVNoiO4D3KhyBIEaZ0oB r9RlqKsLI2F28Hb4=; b=cZ9auEi7eppHiq05ODU9Z+QzeEzxUX+S00/ey41Fav5 QCIK5GktQqIV+vmrnLBCScDFAAAtTsqXyl4kvmn+8VF0WzS6f4K9NQ3GH6u0c33/ 5CkQj/E+BDyWgJxRv5PVz5yUvBX2UYXb0MNC7AyXJkkc5CNQoINHGog6G8At1Zee El1+2cEko5fInzImifmD92ISuwmx9lyet3VuBGiQNIXxvYXQbGPnzFbCvYEuG36F AFhx/C+cu7rDxC2mtPV0bS9c2Vll0K5QsXBW4p6JS0P0r7ASz8aRsGWUqJMdhoo6 bPmmuW3om8uvVQUJbCglafsRErFhMnQNEY8Wj8T/EPg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm2; bh=VORwiH 2LVNoiO4D3KhyBIEaZ0oBr9RlqKsLI2F28Hb4=; b=dnlOwao1ZSAMIeEjfV5j5T v9YJzyxcSBrJO6g9XHWI9fCgvBQ1FfmeJe262D7PcEvHG/bvAVSRcN6R+Oy4Y4OQ CaLTLPl3Ft/exJPfTTTwgDG3aJ0SfD8HH8TnShHyWkxPB8Rpx1liuh/8vjpF/p9a M6JHJwZyGAzCaFQjyytPKTy05KSoJ9YHmjwWxCS2DgdK0DPK2GgtvaAiqu5Ct3Zt NzZbpEhkb0P8Y971So5pUaDofNoH8wpizO1bSeRvGgnrJ2/cUJuccYmkXibvq0T+ ogRPp7z/P7XhzRXVnSaI1Xiv6OzmkeW/wE4mlqock16Qbqfia7HsEgPxxq5A3W9g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrheehgddufeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucfkphepie ejrdduiedtrddvudejrddvhedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id 0568C3280066; Fri, 7 Feb 2020 15:21:58 -0500 (EST) Date: Fri, 7 Feb 2020 12:21:56 -0800 From: Andres Freund To: Stephen Frost Cc: Magnus Hagander , Ian Barwick , Michael Paquier , pgsql-hackers Subject: Re: pg_basebackup and snapshots Message-ID: <20200207202156.vt3jd355qizjjjwc@alap3.anarazel.de> References: <20200205172259.GW3195@tamriel.snowman.net> <20200206070417.GJ23913@paquier.xyz> <20200207020702.o64l2i4mkv5us6oy@alap3.anarazel.de> <20200207195647.GM3195@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200207195647.GM3195@tamriel.snowman.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2020-02-07 14:56:47 -0500, Stephen Frost wrote: > * Andres Freund (andres@anarazel.de) wrote: > > Maybe that's looking too far into the future, but I'd like to see > > improvements to pg_basebackup that make it integrate with root requiring > > tooling, to do more efficient base backups. E.g. having pg_basebackup > > handle start/stop backup and WAL handling, but do the actual backup of > > the data via a snapshot mechanism (yes, one needs start/stop backup in > > the general case, for multiple FSs), would be nice. > > The challenge with this approach is that you need to drop the 'backup > label' file into place as part of this operation, either by putting it > into the snapshot after it's been taken, or by putting it into the data > directory at restore time. Of course, you have to keep track of WAL > anyway from the time the snapshots are taken until the restore is done, > so it's certainly possible, as with all of this, it's just somewhat > complicated. It's not dead trivial, but also doesn't seem *that* hard to me compared to the other challenges of adding features like this? How to best approach it I think depends somewhat on what exact type of backup (mainly whether to set up a new system or to make a PITR base backup) we'd want to focus on. And what kind of snapshotting system / what kind of target data store. Plenty of snapshotting systems allow write access to the snapshot once it finished, so that's one way one can deal with that. I have a hard time believing that it'd be hard to have pg_basebackup delay writing the backup label in that case. The WAL part would probably be harder, since there we want to start writing before the snapshot is done. And copying all the WAL at the end isn't enticing either. For the PITR base backup case it'd definitely be nice to support writing (potentially with callbacks instead of implementing all of them in core) into $cloud_provider's blob store, without having to transfer all data first through a replication connection and then again to the blob store (and without manually implementing non-exclusive base backup). Adding WAL after the fact to the same blob really a thing for anything like that (obviously - even if one can hack it by storing tars etc). Wonder if the the WAL part in particular would actually be best solved by having recovery probe more than one WAL directory when looking for WAL segments (i.e. doing so before switching methods). Much faster than using restore_command, and what one really wants in a pretty decent number of cases. And it'd allow to just restore the base backup (e.g. mount [copy of] the snapshot) and the received WAL stream separately, without needing more complicated orchestration. Perhaps I am also answering something completely besides what you were wondering about? Greetings, Andres Freund