2

I'm planning on setting up streaming backups + WAL streaming with Barman from a PostgreSQL 17 instance. From my reading of the documentation, I don't quite understand what will happen in the scenario that I've planned—if it's valid at all.

Here's my proposed server config to place in /etc/barman.d:

[foobar]
description = "foobar streaming backups"
streaming_archiver = true
backup_method = postgres
conninfo = host=foobar user=barman dbname=postgres
streaming_conninfo = host=foobar user=streaming_barman dbname=postgres
slot_name = barman
create_slot = auto
retention_policy = RECOVERY WINDOW OF 14 DAYS
retention_policy_mode = auto

I was thinking of creating a full backup, then just setting up cron to run barman backup --incremental last foobar once every night, so the first incremental backup would be based on the full backup, and every future backup on the the last incremental one. barman cron is of course running as a minutely job.

But I'm confused about the docs on retention policies. In particular, I don't know what this means in practice:

Block-level incremental backups are not considered in retention policies, as they depend on their parent backups and the root backup. Only the root backup is used to determine retention.

So, given the above setup that I've described, what does Barman actually store? Given that we have the single full backup and daily incremental backups on top of that (plus any streamed WAL files in between), what happens when 14 days have elapsed since the initial full backup? I really don't think the documentation makes this clear.

I know of pg_combinebackup and the concept of synthetic full backups, but am not sure in what (if any) manner Barman is using them to achieve the 14-day recovery window.

Mainly I'm concerned about a) if the 14-day recovery window is actually doable with my backup scheme, and b) Barman not just gradually eating away the disk space on my backup server due to me failing to understand how it works.

Could someone explain Barman's operation in this scenario?

2 Answers 2

3

I was thinking of creating a full backup, then just setting up cron to run barman backup --incremental last foobar once every night

Relying on a single root backup is a mistake.

Recovery Window

Specifies the duration for which backups must be retained to allow recovery to any point within that window. The interval window always ends at the current time and spans backward for the specified period. Barman retains backups and archive logs necessary for point-in-time recovery to any moment within this window.

Since the preceding full backup is required for all subsequent incremental backups to make any sense, and you want to be able to recover to any point in time within the last 14 days, Barman, if it works as advertised, has to keep the original full backup and all incremental backups until "now" to fulfil the promise.

gradually eating away the disk space on my backup server due to me failing to understand how it works

Yes. In addition to that, recovery will take a very long time, because it will have to apply all intermediate incremental backups on top of the root backup.

Instead, you should perhaps schedule the full backup weekly and the incremental backup daily (nightly), which, with the 14 days of recovery window, will result in Barman keeping the last two full backups and all the corresponding incremental backups.

does Barman make use of pg_combinebackup in such a way that after 14 days, it gets run daily via barman cron to create a synthetic full backup from the incremental backup that just became 15 days old?

It does no such thing. It only uses pg_combinebackup when recovering from an incremental backup.

2
  • But the salient question here is, does Barman make use of pg_combinebackup in such a way that after 14 days, it gets run daily via barman cron to create a synthetic full backup from the incremental backup that just became 15 days old? If yes, then there'd always be one (synthetic) full backup and 14 days worth of incrementals on an ongoing basis. Commented Mar 25 at 7:54
  • OK, a discussion on the Barman mailing list clarified this point. Right now there is no such combining of incremental backups, but it's likely an upcoming feature. I'll post an answer. Commented Mar 25 at 13:47
1

As per this discussion on the Barman mailing list, this automatic daily combining of the oldest incremental backup into a sort of "rolling" synthetic full backup would be called an "evergreen" backup with a retention policy.

This feature is not currently implemented, but it is being planned for 2025, perhaps in tandem with PostgreSQL 18 getting a -k/--link option to pg_combinebackup. (Edit: I hadn't noticed @mustaccio's edit to their answer concerning where Barman uses pg_combinebackup when I originally wrote this answer.)

So @mustaccio's advice about taking regular full backups in between incremental ones stands for now, but it looks like this may change in the near future.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.