It seems that each time I attempt to write a script for something like
this, the next day I see one that replaces my 46 lines of code with one
(and actually works). So before I create my usual kludge, can anyone
point me at a good way to do the following?
I create backups each day in directories named for the date in the form
YYYY-MM-DD. I would like to keep as many of these online as I can, so
to do this I need a script to look at the percentage used of my backup
partition and delete the oldest backups until reaching a given
threshold. I guess in pseudo-code it would be something like:
while free-space < threshold do
rm -rf the-oldest-backup
done
I can get the free (or used) percentage by parsing the output from df I
guess (using awk maybe?), but maybe there's a better way to do that. As
the directory names sort by default with oldest first, I guess there's
an easy way to say the-oldest-backup.
Alternatively I suppose I could do something like:
for i in *; exit if free-space < threshold; rm -rf $1; done
Any suggestions most welcome.
TIA
Brian
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com