Pgbackrest, when can I clean up old archive wal files

I am looking at moving my Postgres backups to pgbackups. I just want to make sure I understand when I can clean out old archive wal files. I think the rule is any wal file older that the last full backup I want can be deleted. Is this true?


Hi @wklingler,

You are correct, archived logs preceding the oldest needed full backup can be cleaned out. That’s a general rule that stands for any backup solution, not just pgBackRest. PITR can only be done forward from a full backup, thus your restore time horizon is limited by how old your full backups are, and retention for archived logs should follow that.

In fact, pgBackRest by default should protect you if you set your Archived Logs retention to less time than full backup retention. See pgBackRest Configuration Reference

NOTE: WAL segments required to make a backup consistent are always retained until the backup is expired regardless of how this option is configured.

I would recommend that you operate on the full backups retention, and see whether any older Archived WALs are retained. Changing Archived WALs retention may result in backups that are not suitable for PITR.


1 Like