From: Stephen Frost <sfrost@snowman.net>
To: Mark Johnson <remi9898@gmail.com>
Cc: Adam Brusselback <adambrusselback@gmail.com>
Cc: W.P. <laurentp@wp.pl>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Hot backup in PostgreSQL
Date: Fri, 23 Oct 2020 09:39:36 -0400
Message-ID: <20201023133936.GF16415@tamriel.snowman.net> (raw)
In-Reply-To: <CADZ4tWMp-R=8k4pXcqHcfDZ2JFJjZkNyBSGZtZrvzvR3HJ6E9w@mail.gmail.com>
References: <486ad2c5-01e0-fbf7-b09d-88898b28cdb0@wp.pl>
<CAMjNa7eJZaeNewGq6YwVN=qon87hLiHqJgvQQUZ8B5L4=_0jYw@mail.gmail.com>
<CADZ4tWMp-R=8k4pXcqHcfDZ2JFJjZkNyBSGZtZrvzvR3HJ6E9w@mail.gmail.com>
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 database
> 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
from 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-LOWLEVEL-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.
>
> [1]
> https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-BACKUP.
>
>
> On Thu, Oct 22, 2020 at 11:14 AM Adam Brusselback <adambrusselback@gmail.com>
> wrote:
>
> > > how to do "hot backup" (copying files) while database running?
> > As others have shown, there are ways to do this with PG's internal tooling
> > (pg_basebackup).
> >
> > However, I would highly recommend you use an external backup tool like
> > pgbackrest [1] to save yourself the pain of implementing things incorrectly
> > 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/
> >
Attachments:
signature.asc (application/pgp-signature, 818B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: sfrost@snowman.net, remi9898@gmail.com, adambrusselback@gmail.com, laurentp@wp.pl
Subject: Re: Hot backup in PostgreSQL
In-Reply-To: <20201023133936.GF16415@tamriel.snowman.net>
References: <486ad2c5-01e0-fbf7-b09d-88898b28cdb0@wp.pl> <CAMjNa7eJZaeNewGq6YwVN=qon87hLiHqJgvQQUZ8B5L4=_0jYw@mail.gmail.com> <CADZ4tWMp-R=8k4pXcqHcfDZ2JFJjZkNyBSGZtZrvzvR3HJ6E9w@mail.gmail.com> <20201023133936.GF16415@tamriel.snowman.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox