315 points · by code_reader · 2y ago · 57 comments
> we were taking Postgres base backups (to Google Cloud Storage)
Rule #1 of backups - do not host backups in the same location as the primary
The canonical strategy is the 3-2-1 rule: three copies, two different media, one offsite; but there are variations, so I'd consider this the minimum.
This is a distant second priority to ensuring any reliable backup.
Oh man that is my nightmare. Nothing says "broken system" like having to circumvent the system to get something done.
If your payments fail for whatever reason google will happily kill your entire account after a few weeks with nothing other than a few email warnings (which obviously routinely get ignored)
There will likely be some recovery process after restoring / rollback as it is effectively an unclean shutdown but this is unlikely to be much slower than regular backup restoration.
If you're interested in this topic, Robert Haas (the author/committer of the feature) also wrote two posts after I published this, which talk more about incremental backup:
http://rhaas.blogspot.com/2024/01/incremental-backup-what-to...
http://rhaas.blogspot.com/2024/01/incremental-backups-evergr...
I'm actually subscribed to your blog in my RSS reader, but I completely missed this article (any many others) when it was published because it didn't show up in the RSS feed.
I have been missing this for the last....15 years. I hope that it will make it into the final release.
I wonder how much time combining the backups will take If you have 100 or 500GB, the tests didn't address this. I might have to spin up an instance to try it out.
Now if your db works like append only, this may need t be as big as a savings as someone who updates the same records a lot (as at incremental backup time it only needs to save the final values of those records).
This could be used in replication topographies and scenarios. Maybe PG 18.
I’ll have to read how the summarizer works specifically
Changed block tracking is one option, or failing that, segmenting files at logical boundaries, checksumming those segments, and comparing the checksum with those of previous backup segments to see if that segement has changed (with a strategy for checksum collision avoidance).
I'm being dramatic obviously but like... less CPU cycles, less network bandwidth, etc. etc.
If adopted by top 100 "large" database/operations, is it as much as like 100 people giving up their gas/petrol/diesel car?
[1] for example https://about.gitlab.com/blog/2019/02/13/delayed-replication...
Let’s say a full backup takes 3 hours and an incremental one 3 minutes.
Let’s say I want at most 3 hours of lag in my backups. That would mean 3 hours every 3 hours. That is about 720 hours per month for a full backup or 720 minutes (12 hours) for incremental backups. Let’s say we Still do a full one once a day then that is still 102 hours per month in total.
Even if you do 1 incremental per hour you’d end up at 36 hours a month. If 3 minutes were true for the every 3 hour scenario, the every 1 hour scenario would also mean shorter backups so maybe 1 minute, which adds up to 12 hours.
All this to say that it might be more efficient.
AKA Recovery Point Objective (RPO)
To do WAL replay (= Point In Time Recovery PITR) you'll still need the full incremental WAL files that take up more space (and is already available in PG since like ten years I think).
PS:Usually you'll also take one full pg_basebackup snapshot on regular basis to avoid replaying too much and to discard older snapshot.
So maybe the gain would be to combine theses process. Keep incremental WAL for short term PITR but apply incremental backup to snapshot to reduce long term backup size.
Anyway this is a really cool mew option!
The incremental backup would be just the WAL segments excluding the base backup.
With this new feature, the WAL segments you need to store are much, much smaller.
Not exactly. Pgbackrest can do incremental backups that are restored by applying file system level diffs (stored in incremental backup) to the base backup. WALs are only involved at the very last step when restore process is finalized by applying WALs that were generated during BACKUP step itself. But that's not pgbackrest limitation, that's how any Postgres restore process works.
EDIT: "how any Postgres restore process works" that restore a backup done from a live database that is being written to when backup is taking place.