Removing old files

Of course, we might not need to keep transaction logs forever. WAL-E also provides a simple command for purging old WAL files that have served their purpose. We're mainly concerned with high availability, so being able to restore from a backup taken several weeks ago, probably isn't necessary. To remove these old files, we can use a command like this:

envdir /etc/wal-e/env wal-e delete --confirm retain 2

This would remove all but WAL files for the two most recent backup operations. The --confirm flag commits the change; otherwise WAL-E errs on the side of caution and considers the command a dry run.

Unfortunately, this only really works if we've performed a backup with WAL-E. If our database is too large for this to be ...

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.