Starting from commit a1bb778 I have modified the cleanup code so that it works well on outdir and html-outdir AND it is simplified AND it works for monthly reports.
The logic I applied is similar to the one before
EXCEPT for the case where there is NO 'noclean' and NO 'retention' flags specified.
In this case, the current code was doing BIN cleanup for the previous month and older, even if it was run on the 1st of the month.
I have put in place a more coherent strategy (as far as I believe it is):
do BIN cleanup by simulating a retention period of 5 weeks, which is about 1 month sliding window.
So the sum-up of the strategy is:
###
### Explanation:
###
### Logic for the BINARY storage ($outdir) SHOULD be:
### If ('noclean')
### do nothing (keep everything)
### If (NO 'noclean') and (NO 'retention'):
### use an arbitrary retention duration of: 5 weeks
### remove BINARY files older than LAST_PARSED_MONTH-retention
### DO NOT CHECK for HTML file existence as OLD HTML files may be deleted by external tools
### which may lead to BINARY files NEVER deleted
### If (NO 'noclean') and ('retention'):
### remove BINARY files older than LAST_PARSED_MONTH-retention
### DO NOT CHECK for HTML file existence as OLD HTML files may be deleted by external tools
### which may lead to BINARY files NEVER deleted
###
### Logic for the HTML storage ($html_outdir || $outdir) SHOULD be:
### DO NOT check 'noclean' as this flag is dedicated to BINARY files
### If (NO 'retention'):
### do nothing (keep everything)
### If ('retention'):
### remove HTML folders/files older than LAST_PARSED_MONTH-retention (= y/m/d):
### days older than d in y/m/d
### months older than m in y/m/d
### years older than y in y/m/d
###
And I have done extensive tests on the following cases:
(NO 'noclean') and (NO 'retention') and (outdir+html-outdir)
(NO 'noclean') and (NO 'retention') and (outdir only)
(NO 'noclean') and ('retention') and (outdir+html-outdir)
(NO 'noclean') and ('retention') and (outdir only)
('noclean') and (NO 'retention') and (outdir+html-outdir)
('noclean') and (NO 'retention') and (outdir only)
('noclean') and ('retention') and (outdir+html-outdir)
('noclean') and ('retention') and (outdir only)
ALL the tests passed OK
I can provide you with command lines and debug outputs.
Hi @darold
FIX for Issue https://github.com/darold/pgbadger/issues/776
776
Starting from commit a1bb778 I have modified the cleanup code so that it works well on outdir and html-outdir AND it is simplified AND it works for monthly reports.
The logic I applied is similar to the one before EXCEPT for the case where there is NO 'noclean' and NO 'retention' flags specified. In this case, the current code was doing BIN cleanup for the previous month and older, even if it was run on the 1st of the month. I have put in place a more coherent strategy (as far as I believe it is): do BIN cleanup by simulating a retention period of 5 weeks, which is about 1 month sliding window.
So the sum-up of the strategy is:
And I have done extensive tests on the following cases: (NO 'noclean') and (NO 'retention') and (outdir+html-outdir) (NO 'noclean') and (NO 'retention') and (outdir only) (NO 'noclean') and ('retention') and (outdir+html-outdir) (NO 'noclean') and ('retention') and (outdir only) ('noclean') and (NO 'retention') and (outdir+html-outdir) ('noclean') and (NO 'retention') and (outdir only) ('noclean') and ('retention') and (outdir+html-outdir) ('noclean') and ('retention') and (outdir only)
ALL the tests passed OK
I can provide you with command lines and debug outputs.
Thanks in advance