Pg-archivecleanup Must Specify Oldest Kept Wal File ((better))
OLDEST_WAL=$(ls -1 $ARCHIVE_PATH | head -n 1) # NOT safe for production - just example
: When you run the tool manually (e.g., via cron or a script), you must manually determine this "restart point". If you omit it, the tool terminates with this error to prevent deleting files still needed for a consistent restore. How to Resolve the Error
Often, you want to keep everything after a certain base backup. A common pattern: pg-archivecleanup must specify oldest kept wal file
The corrected configuration should look like this:
: Always check that OLDEST_WAL is non-empty before calling pg_archivecleanup . OLDEST_WAL=$(ls -1 $ARCHIVE_PATH | head -n 1) #
: Scans the archive for .backup history files and keeps all WAL segments required for the last base backups.
pg_archivecleanup -n /archive 000000010000001A000000F0 A common pattern: The corrected configuration should look
All WAL segments less than 000000010000001A000000E1 (i.e., ...E0 and earlier) will be deleted.
for newer versions), where the standby server automatically tells the utility which file is the oldest one it still needs. PostgreSQL Common Usage Example When running manually to clean up an archive located at /mnt/server/archivedir pg_archivecleanup /mnt/server/archivedir 000000010000000000000010 Use code with caution. Copied to clipboard
