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 1mf3Xi-0001By-D3 for pgsql-general@arkaria.postgresql.org; Mon, 25 Oct 2021 17:13:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mf3Xf-0007w6-PM for pgsql-general@arkaria.postgresql.org; Mon, 25 Oct 2021 17:13:47 +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 1mf3Xf-0007vx-FB for pgsql-general@lists.postgresql.org; Mon, 25 Oct 2021 17:13:47 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mf3Xb-0003Ze-KL for pgsql-general@lists.postgresql.org; Mon, 25 Oct 2021 17:13:47 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 69AC85F799; Mon, 25 Oct 2021 13:13:42 -0400 (EDT) Date: Mon, 25 Oct 2021 13:13:42 -0400 From: Stephen Frost To: Mladen Gogala Cc: Lucas , pgsql-general@lists.postgresql.org Subject: Re: ZFS filesystem - supported ? Message-ID: <20211025171342.GH20998@tamriel.snowman.net> References: <49ijds_99IK_4iDOHuZH8CJsKGZw7DEVtJPf0s_oPEvUKwFewHcDQFCUnutcA9GYIkOrRfFAKRsyj0ZFN9ECAbLm-NYPR8jMxTl-RU-U3hA=@protonmail.ch> <1e0db1d2-6a9e-f5f7-44af-e7a1997bafcf@gmail.com> <917520e4-0023-2842-db5f-2e1cbd72b004@gmail.com> <741d4f14b64a45d7a9670042ac8ecf66@sud0.nz> <77b0fb54-64f5-833d-19ba-2c731af1f700@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+TFC1kkuuXJmyCU6" Content-Disposition: inline In-Reply-To: <77b0fb54-64f5-833d-19ba-2c731af1f700@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+TFC1kkuuXJmyCU6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Mladen Gogala (gogala.mladen@gmail.com) wrote: > On 10/23/21 23:12, Lucas wrote: > >This has proven to work very well for me. I had to restore a few backups > >already and it always worked. The bad part is that I need to stop the > >database before performing the Snapshot, for data integrity, so that mea= ns > >that I have a hot-standby server only for these snapshots. > >Lucas >=20 > Actually, you don't need to stop the database. You need to execute > pg_start_backup() before taking a snapshot and then pg_stop_backup() when > the snapshot is done. You will need to recover the database when you fini= sh > the restore but you will not lose any data. I know that pg_begin_backup() > and pg_stop_backup() are deprecated but since PostgreSQL doesn't have any > API for storage or file system snapshots, that's the only thing that can > help you use storage snapshots as backups. To my knowledge,the only datab= ase > that does have API for storage snapshots is DB2. The API is called "Advan= ced > Copy Services" or ACS. It's documented here: >=20 > https://www.ibm.com/docs/en/db2/11.1?topic=3Drecovery-db2-advanced-copy-s= ervices-acs >=20 > For Postgres, the old begin/stop backup functions should be sufficient. No, it's not- you must also be sure to archive any WAL that's generated between the pg_start_backup and pg_stop_backup and then to be sure and add into the snapshot the appropriate signal files or recovery.conf, depending on PG version, to indicate that you're restoring from a backup and make sure that the WAL is made available via restore_command. Just doing stat/stop backup is *not* enough and you run the risk of having an invalid backup or corruption when you restore. If the entire system is on a single volume then you could possibly just take a snapshot of it (without any start/stop backup stuff) but it's very risky to do that and then try to do PITR with it because we don't know where consistency is reached in such a case (we *must* play all the way through to the end of the WAL which existed at the time of the snapshot in order to reach consistency). In the end though, really, it's much, much, much better to use a proper backup and archiving tool that's written specifically for PG than to try and roll your own, using snapshots or not. Thanks, Stephen --+TFC1kkuuXJmyCU6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJhduXFAAoJEO1sijiDR2RVra4QAMIdsyk9szjE0+c9mZRLDDuB knBX8+irHIHBk/xE7PPf2y9HiXEa//8Xq1ND79vdcF5mwXRGEQCMTWs62g22Ade6 A3nCxeIjdUoLRfX9IPO2LLbxKJvliDFf79uvXkyN4ujqYbwCOCykvp81AC81S/CH OtrHbtaeOOTw13agpXqqZKp4OKx/No0dXkg6OAbiQnRuVJJR+Jl9x5wgM1YvFdSe Qp/2hZYrvKtRjiiccz2DvvjRUgSDxEQ1+5V8npFOSifiVdBuNmSb7ndBOjwNrACJ pRc6o7CquGlKypvHnmu6uuLmFVJcebZg81uhynOdQZGMPdO9PtJDrdoMKXnX06y+ CBaEZJsqxHSAhOSluLbiY0eilhA/0N80kDcKGoe2Ye69Bk0jC3S/tOSIPjKVSPV7 5UJZjyj6EBWlz2O8tYz2Nc9BIgXLCqDAMX4xOgNiz2xIdUPiYjhSfV5Hf7WRZAN2 crg8CbHNnj3zJ8s3p0HUFP2XdbzfTD6eP6Q/BnJpJazxyIewvDBKUKZknRW4rolU Qnwcw3fi21cfuRkYNgrHSOStaXt2Lak/Q9JfhCClq7RuFK2T4qYkicfNtvRdMkcf BsqMycpfIZzW3ww65lTgGKYXll56sXYbKryBkvVWGM5Emso/jD61y5OSTR0YIbXt hFiwjr+Nll5Hd36WAx/t =/KAi -----END PGP SIGNATURE----- --+TFC1kkuuXJmyCU6--