Обсуждение: pgbackrest periodic WAL backups?
Hi, I've got a full pgbackrest backup in crontab that runs weekly, and a diff backup that runs nightly. However, I can't find any way to do hourly WAL backups. Or does "archive_command = 'pgbackrest --stanza=demo archive-push %p'" just keep things automatically caught up, obviating the need for periodic WAL backups (as are needed in other RDBMSs)? Thanks -- Angular momentum makes the world go 'round.
Greetings, * Ron (ronljohnsonjr@gmail.com) wrote: > I've got a full pgbackrest backup in crontab that runs weekly, and a diff > backup that runs nightly. However, I can't find any way to do hourly WAL > backups. > > Or does "archive_command = 'pgbackrest --stanza=demo archive-push %p'" just > keep things automatically caught up, obviating the need for periodic WAL > backups (as are needed in other RDBMSs)? Yes and no. With the archive command, every WAL archived will be pushed to the archive more-or-less immediately (or, at least, as fast as your system can get it there, if you enable parallel archiving in pgbackrest), however, WAL files have a size (by default 16MB) and if you have a very slowly changing system then it could possibly be hours between WALs being pushed to the archive by archive_command. You can address that risk by enabling archive_timeout, which will make PostgreSQL archive the WAL file even if it isn't full after a certain amount of time, reducing the potential data loss window. pgBackRest will compress the WAL file, but that might not be as effective as you'd like on older versions of PG because WAL files used to have either potentially a bunch of garbage at the end (due to being recycled) or possibly WAL headers through the end of the archive (which is better than garbage but still not free). We've finally, I believe, got it such that the end of WAL is zero'd out, leading to very little overhead from having a low archive_timeout value set, but I don't recall offhand if that got into v11 or if it's coming in v12. We're looking at improving pgBackRest to actually scan the WAL file internals itself to identify the end-of-WAL and possibly eliminate the garbage or WAL headers at the end of a not-full WAL segment but it isn't very high on the list currently. Thanks! Stephen
Вложения
On 12/09/2018 01:10 PM, Stephen Frost wrote: > Greetings, > > * Ron (ronljohnsonjr@gmail.com) wrote: >> I've got a full pgbackrest backup in crontab that runs weekly, and a diff >> backup that runs nightly. However, I can't find any way to do hourly WAL >> backups. >> >> Or does "archive_command = 'pgbackrest --stanza=demo archive-push %p'" just >> keep things automatically caught up, obviating the need for periodic WAL >> backups (as are needed in other RDBMSs)? > Yes and no. With the archive command, every WAL archived will be pushed > to the archive more-or-less immediately (or, at least, as fast as your > system can get it there, if you enable parallel archiving in > pgbackrest), however, WAL files have a size (by default 16MB) and if you > have a very slowly changing system then it could possibly be hours > between WALs being pushed to the archive by archive_command. > > You can address that risk by enabling archive_timeout, which will make > PostgreSQL archive the WAL file even if it isn't full after a certain > amount of time, reducing the potential data loss window. I thought checkpoint_timeout forced a WAL switch. -- Angular momentum makes the world go 'round.
Hi Ron,
Go through this link. hope this will help you.
https://pgbackrest.org/configuration.html#section-archive/option-archive-timeout
Go through this link. hope this will help you.
https://pgbackrest.org/configuration.html#section-archive/option-archive-timeout
On Sun, Dec 9, 2018 at 9:35 PM Ron <ronljohnsonjr@gmail.com> wrote:
Hi,
I've got a full pgbackrest backup in crontab that runs weekly, and a diff
backup that runs nightly. However, I can't find any way to do hourly WAL
backups.
Or does "archive_command = 'pgbackrest --stanza=demo archive-push %p'" just
keep things automatically caught up, obviating the need for periodic WAL
backups (as are needed in other RDBMSs)?
Thanks
--
Angular momentum makes the world go 'round.
On 12/10/18 12:16 AM, Shreeyansh Dba wrote: > > Go through this link. hope this will help you. This option is not helpful in this case. It defines the amount of time that pgBackRest will wait for WAL to arrive in the archive for the check and backup commands. The Postgres option archive_timeout will do the trick. There's some discussion of that here: https://pgbackrest.org/user-guide.html#quickstart/configure-archiving Regards, -- -David david@pgmasters.net
On 12/9/18 5:24 PM, Ron wrote: > On 12/09/2018 01:10 PM, Stephen Frost wrote: >> >> You can address that risk by enabling archive_timeout, which will make >> PostgreSQL archive the WAL file even if it isn't full after a certain >> amount of time, reducing the potential data loss window. > > I thought checkpoint_timeout forced a WAL switch. Checkpoints do not automatically switch WAL. archive_timeout is the way to go. Postgres >= 9.5 will mostly zero the remainder of the WAL and Postgres >= 11 will entirely zero it. Either way, compression works well. For production systems I generally use archive_timeout=900 so a segment is archived every 15 minutes when there is not enough activity to force a switch naturally. Note that if there is *zero* activity then there in no need for a WAL switch but some older versions would do so anyway if wal_level=hot_standby. We fixed that in Postgres 10. Regards, -- -David david@pgmasters.net
On 12/10/2018 07:37 AM, David Steele wrote: > On 12/9/18 5:24 PM, Ron wrote: >> On 12/09/2018 01:10 PM, Stephen Frost wrote: >>> You can address that risk by enabling archive_timeout, which will make >>> PostgreSQL archive the WAL file even if it isn't full after a certain >>> amount of time, reducing the potential data loss window. >> I thought checkpoint_timeout forced a WAL switch. > Checkpoints do not automatically switch WAL. archive_timeout is the way > to go. Thanks for the clarification. -- Angular momentum makes the world go 'round.