Handy backup rotation bash script
Posted on 2012-08-29
I have bunch of files named xxx-20111201.gz, xxx-20111202.gz, ..., xxx-20111231.gz, ...., xxx-20120830.gz.
I need to rotate this files leaving only two last backups in each month.
The problem is that I do not always know if there will be backups for 30, 31st of each month. There is a possibility that all of them will be missing except for example couple for the first and second day of the month than I need to keep this two avalable backups for this month.
Is there any handy way to do this rotation in a bash script?