pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How does pg_basebackup manage to create a snapshot of the filesystem?
3+ messages / 3 participants
[nested] [flat]

* How does pg_basebackup manage to create a snapshot of the filesystem?
@ 2020-03-19 22:19 Dennis Jacobfeuerborn <dennisml@conversis.de>
  2020-03-19 22:26 ` Re: How does pg_basebackup manage to create a snapshot of the filesystem? Christophe Pettus <xof@thebuild.com>
  2020-03-23 17:55 ` Re: How does pg_basebackup manage to create a snapshot of the filesystem? Stephen Frost <sfrost@snowman.net>
  0 siblings, 2 replies; 3+ messages in thread

From: Dennis Jacobfeuerborn @ 2020-03-19 22:19 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi,
I'm currently trying to understand how backups work. In the
documentation in section "25.2. File System Level Backup" it says that
filesystem level backups can only be made when the database if offline
yet pg_basebackup seems to do just that but works while the database is
online. Am I misunderstanding something here or does pg_basebackup use
some particular features of Postgres to accomplish this?

Regards,
  Dennis





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How does pg_basebackup manage to create a snapshot of the filesystem?
  2020-03-19 22:19 How does pg_basebackup manage to create a snapshot of the filesystem? Dennis Jacobfeuerborn <dennisml@conversis.de>
@ 2020-03-19 22:26 ` Christophe Pettus <xof@thebuild.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Christophe Pettus @ 2020-03-19 22:26 UTC (permalink / raw)
  To: Dennis Jacobfeuerborn <dennisml@conversis.de>; +Cc: pgsql-general@lists.postgresql.org



> On Mar 19, 2020, at 15:19, Dennis Jacobfeuerborn <dennisml@conversis.de> wrote:
> I'm currently trying to understand how backups work. In the
> documentation in section "25.2. File System Level Backup" it says that
> filesystem level backups can only be made when the database if offline
> yet pg_basebackup seems to do just that but works while the database is
> online. Am I misunderstanding something here or does pg_basebackup use
> some particular features of Postgres to accomplish this?

pg_basebackup does, indeed, take an inconsistent copy of the file system while it is running; what allows it to bring the database back up to consistency is the write-ahead log segments that are created while pg_basebackup is running.  That's why it is important to have all of the WAL segments created during the run (which is what --wal-method=stream provides you).
--
-- Christophe Pettus
   xof@thebuild.com






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How does pg_basebackup manage to create a snapshot of the filesystem?
  2020-03-19 22:19 How does pg_basebackup manage to create a snapshot of the filesystem? Dennis Jacobfeuerborn <dennisml@conversis.de>
@ 2020-03-23 17:55 ` Stephen Frost <sfrost@snowman.net>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephen Frost @ 2020-03-23 17:55 UTC (permalink / raw)
  To: Dennis Jacobfeuerborn <dennisml@conversis.de>; +Cc: pgsql-general@lists.postgresql.org

Greetings,

* Dennis Jacobfeuerborn (dennisml@conversis.de) wrote:
> I'm currently trying to understand how backups work. In the
> documentation in section "25.2. File System Level Backup" it says that
> filesystem level backups can only be made when the database if offline
> yet pg_basebackup seems to do just that but works while the database is
> online. Am I misunderstanding something here or does pg_basebackup use
> some particular features of Postgres to accomplish this?

A simple tar-based backup as discussed in 25.2 can only be done with the
database off-line, but if you're wondering what pg_basebackup is doing
under the covers then you should be reading through 25.3, which talks
about the PostgreSQL WAL, how a backup can be taken in an online manner
provided you retain the WAL that was created during the backup, how to
restore a backup taken in that manner, etc.

All that said, I don't recommend rolling your own backup solution for
PG.  There's a number of good ones out there, starting with
pg_basebackup if you really just need something simple.

Thanks,

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2020-03-23 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 22:19 How does pg_basebackup manage to create a snapshot of the filesystem? Dennis Jacobfeuerborn <dennisml@conversis.de>
2020-03-19 22:26 ` Christophe Pettus <xof@thebuild.com>
2020-03-23 17:55 ` Stephen Frost <sfrost@snowman.net>

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