we want to remove
archived WAL log files which are no longer needed The WAL files are all numerical –
however the backup file has the checkpoint appended to it – eg.
00009012514000916.A0AC91.backup. You need to examine the contents of this
file to find the earliest file needed (it’s usually the one just before
it – i.e. 00009012514000916 in this case) and any numerically later
than the .backup file. Also you wouldn’t particular need
any heavy programming – I’m sure a simple shell script could be
written in bash to pick out the correct files.
Pg_stop_backup() returns the checkpoint
record – something like 9/A0AC91 – this is purely a guess, but you
might be able to find which backup file contains this checkpoint by taking the digits
after the forward-slash in the checkpoint (i.e. A0AC91 in this case), then
finding the filename that contains this – in my example it’s
00009012514000916.A0AC91.backup, and grep the file for the number after the
text “Start WAL Location: “ in this file – then remove
anything numerically less. It’d be a very “bitty”
process, but I’m certain it could be done – it would need heavy
testing over a period of backups though to ensure the wrong files are not being
deleted.
The WAL archive command can be set to use
either cp or mv – then why not have a regular cronjob that runs a shell
script to add any new files to your tar archive every time a new file is
detected in your WAL-archive directory?
|