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 1kVxID-0007YZ-MQ for pgsql-general@arkaria.postgresql.org; Fri, 23 Oct 2020 13:39:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVxIC-0005yh-KB for pgsql-general@arkaria.postgresql.org; Fri, 23 Oct 2020 13:39:40 +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 1kVxIC-0005ya-CJ for pgsql-general@lists.postgresql.org; Fri, 23 Oct 2020 13:39:40 +0000 Received: from tamriel.snowman.net ([70.109.60.50]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVxI9-0006Br-Vn for pgsql-general@lists.postgresql.org; Fri, 23 Oct 2020 13:39:39 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id A00D35F799; Fri, 23 Oct 2020 09:39:36 -0400 (EDT) Date: Fri, 23 Oct 2020 09:39:36 -0400 From: Stephen Frost To: Mark Johnson Cc: Adam Brusselback , "W.P." , pgsql-general Subject: Re: Hot backup in PostgreSQL Message-ID: <20201023133936.GF16415@tamriel.snowman.net> References: <486ad2c5-01e0-fbf7-b09d-88898b28cdb0@wp.pl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JkW1gnuWHDypiMFO" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --JkW1gnuWHDypiMFO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Mark Johnson (remi9898@gmail.com) wrote: > User managed backups in PostgreSQL work very similar to what you know from > Oracle. You first place the cluster in backup mode, then copy the databa= se > files, and lastly take the cluster out of backup mode. The first and last > steps are done using functions pg_start_backup('label',false,false) and > pg_stop_backup(false, false). [1]. Just to be clear for the archives, the above is *not* sufficient to have a consistent and valid backup- you must also ensure that archive_command (or some other system) is configured to capture all of the WAL produced =66rom the start to the end of the backup, and you need to make sure that a backup_label file is created in the backup (using the results of pg_stop_backup). Some of this is discussed in the 'low level API' part of the documentation, as linked before: https://www.postgresql.org/docs/13/continuous-archiving.html#BACKUP-LOWLEVE= L-BASE-BACKUP Though it's really best, as mentioned, to use an existing tool that's been written to ensure all of this is done correctly and not to try and build your own. Thanks, Stephen > If you use a utility supplied with PostgreSQL such as pg_basebackup, it > does these steps for you. If you are using a specific non-PostgreSQL > utility (i.e., Dell Networker or IBM Tivoli) see their documentation for > specifics. >=20 > [1] > https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-AD= MIN-BACKUP. >=20 >=20 > On Thu, Oct 22, 2020 at 11:14 AM Adam Brusselback > wrote: >=20 > > > how to do "hot backup" (copying files) while database running? > > As others have shown, there are ways to do this with PG's internal tool= ing > > (pg_basebackup). > > > > However, I would highly recommend you use an external backup tool like > > pgbackrest [1] to save yourself the pain of implementing things incorre= ctly > > and ending up with non-viable backups when you need them most. I'm not > > affiliated with them at all, but have just used pgbackrest in production > > for years now with great results. It takes care of PITR, and manages > > backup retention (and associated WAL retention). Those can be a bit of a > > pain to do manually otherwise. > > > > Just my $0.02, hope it helps! > > > > 1. https://pgbackrest.org/ > > --JkW1gnuWHDypiMFO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJfkt0YAAoJEO1sijiDR2RVp1MP/ikmkcfBeKz4JpzgEC27B5go 2R0zVQBy6SfPRgpUM07a3lQpHzGUjDjcS59QcraLWQBpD7xPg4fS+rRZ1Oilh6pE oeU+YIIGNPnrAnf0aE3KxZjfW84uXI9IvwJ9Z+5xyq9pF6pWw3c0K4Hmt0sS9LZl WUVXkedM4whm7J+ggJ9kbpXClB3ea8KhIp1t5lT4hDqQmSWofJSQjOzGYGedhOgh Gu2AKC/FDYYQuR/x4So7zG/B1pANS02H10ub1R6g72X6k9gloyT1ZMZGn/osWR39 D+mn88zi8QihNdaKEXpSpzS7O3+0Z/RN/etz0+8fo3FS+U2Y0mxsShuosF2Bj0H+ l1PGr0EGqrLbLdtjUDCx4wwUSC4yzjxqhTWVFh4epjHU00iwwSd1/On6902ey68F vG4K2P/hFunFOQuV8VB6OJSq8bOWnRIIgGdy4KkzOF82GhxU1KGKZQdFYb8VmRQ5 1llRfGSvu4BIjYa2Sdn2ffVwULivDpWwCguWuY+27E+h4qe2pm9n9JIK6GbKYH9g D2mKvN7tIbGxMCDfjiWz8hrQ0y+mGNtqfoNx1jTBPMPgoMuPw1/bExbWzK2t97oI RtiOceiUsZ08WTozKZ5H5yurlripsPZvx2vzvYFCbf8JOKItrYOuL+XBxqGxbnPV 1lEqtXtw7mhoRq1cUFH3 =nIR9 -----END PGP SIGNATURE----- --JkW1gnuWHDypiMFO--