# How can we configure the PostgreSQL14 wal retention policy?

**URL:** <https://forums.percona.com/t/how-can-we-configure-the-postgresql14-wal-retention-policy/16765>\
**Category:** PostgreSQL\
**Created:** [July 26, 2022, 8:03pm UTC](https://forums.percona.com/t/how-can-we-configure-the-postgresql14-wal-retention-policy/16765 "2022-07-26T20:03:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [July 26, 2022, 8:03pm UTC](https://forums.percona.com/t/how-can-we-configure-the-postgresql14-wal-retention-policy/16765/1 "2022-07-26T20:03:13Z")

</div>

Hi Folks,

How can we set the automatic retention policy for the pg\_xlog and archive logs in Postgresql 14? I am little confusing about the archeve logs and pg xlogs retention or how can we over come the disk spaces issues?  
NOTE: Master node has two replica servers.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [July 27, 2022, 2:42pm UTC](https://forums.percona.com/t/how-can-we-configure-the-postgresql14-wal-retention-policy/16765/2 "2022-07-27T14:42:24Z")

</div>

Can someone please help on this?

---

<div class="post-metadata">

**Author:** ![Agustin\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/agustin_g/32/14111_2.png) [@Agustin\_G](https://forums.percona.com/u/Agustin_G)\
**Post date:** [July 27, 2022, 11:35pm UTC](https://forums.percona.com/t/how-can-we-configure-the-postgresql14-wal-retention-policy/16765/3 "2022-07-27T23:35:20Z")

</div>

Hi Naresh,  
I just replied over your other question related to backups, in which I mentioned pgBackRest. If you are going to use it, you can make the most out of it by setting it up for the WAL archival too:

> **[How pgBackRest is Addressing Slow PostgreSQL WAL Archiving Using Asynchronous...](https://www.percona.com/blog/2020/12/01/how-pgbackrest-is-addressing-slow-postgresql-wal-archiving-using-asynchronous-feature/)**
>
> How pgBackRest is addressing slow PostgreSQL WAL Archiving using its Asynchronous archiving feature.

You may also want to read up on how to quickly (and manually) clean up WALs if you are in dire need of disk space, by using pg\_archivecleanup:

> **[PostgreSQL WAL Retention and Clean Up: pg\_archivecleanup - Percona Database...](https://www.percona.com/blog/2019/07/10/wal-retention-and-clean-up-pg_archivecleanup/)**
>
> PostgreSQL WAL retention is a very important topic for database management. A program named pg\_archivecleanup is useful in maintaining the WAL retention.

If you are currently having issues with the archival process, you should check the PostgreSQL error log for clues on why it may be failing, and also check the configuration variables are correctly set.

Let me know if this helped.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [August 1, 2022, 4:43pm UTC](https://forums.percona.com/t/how-can-we-configure-the-postgresql14-wal-retention-policy/16765/4 "2022-08-01T16:43:26Z")

</div>

Hi @Agustin_G

Thank so much for the suggestion.
