Delete Postgres Archive

From Define Wiki
Jump to navigation Jump to search

Delete Old Postgres Archive

Note: PCM 3.x

HPC 3.0 keep the data of the ReportDB in PostgreSQL database. 
Any host statuses, job statuses are recorded in the database. 
The transactions are also logged in this pg_wal directory as archive.

As a result, a 16MB get created regularly pending the number of jobs submitted and the 
host status. This can quickly fill up the /var disk partition.

These archive files only use for roll forward on the 'Standby server' and not use on the
headnode for recovery. The old archive can be remove up to the last few days.

There is no practical recommendation from Platform on how may days worth of Postgres
archive should be retain. Perhaps just the last 3 to 5 days.

To remove the old archive file, use pg_archivecleanup. See below:
  • Remove old Postgres archive file

Ref: http://developer.postgresql.org/pgdocs/postgres/pgarchivecleanup.html

pg_archivecleanup -d /var/lib/pgsql/9.0/data/pg_wal 000000010000000000000042.00000046.backup

Note:

pg_archivecleanup has a strange syntax. 
'000000010000000000000042' means from file '00000042' to file '00000046' and beyond 
should be retain. Unable to find an explanation on the web for the syntax.

It can be just '000000010000000000000042.00000043.backup'. You do need prefixing 43 with
000000, otherwise get syntax error/invalid filename.