I'm not that great with postgres but i was able to setup replication following this tutorial: https://www.howtoforge.com/tutorial/how-to-set-up-master-slave-replication-for-postgresql-96-on-ubuntu-1604/ It all works great but the amount of WAL files is getting ridiculous. I assume the slave should tell them master to remove old files, but I'm not sure how to do that. I have the same settings as in the tutorial. I've already tried to "manually" clean them, which lead to a ton of problems. But right now the i'm using 30GB of space for the files and i'm afraid to do any more massive imports into my db because i will run out of space

2 Answers 2


I think you're looking for the archive_cleanup_command setting in your recovery.conf file:

archive_cleanup_command = 'pg_archivecleanup archivelocation %r'

See the docs or this post for more info.

  • I tried this, added the command with proper archive location on my slave's recovery.conf file. restarted postgres, replication still works, but it's still not cleaning logs. and i'm already at 180GB on my master.
    – Cremz
    Aug 10, 2018 at 9:40

If the only reason you are using a WAL archive is to do log shipping for the replication (as opposed to other reasons, like wanting to maintain the ability to do PITR), then you should stop using a WAL archive and switch to solely using streaming replication instead. To insure enough WAL is kept to support the replica you can use replication slots rather than a WAL archive, that way the replica does report back on which files can be removed and master removes, just like you want.

  • only did WAL archive because of the tutorial. i just want my master to be used for heavy processing (powerful server) and then send the data to the slave so i can read from it (also half way across the world). I don't need any PITR
    – Cremz
    Aug 10, 2018 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.