I have been tasked with cleaning up some daily backups and I want to automate this. I have decided that Perl might just do the trick except up until about a week ago I did not know much about it. I have been doing some homework but I am stuck and would like some help.
Here is the description of problem:
When backup is run from Sharepoint it creates a new folder with a sequentially increasing name. The backups are only run during the work week. I need to delete all but 4 of the folders and only if they are older than 4 days. I need a script that runs every day but ensures I have no more or less than 4 folders the backup directory after each execution.
Below you'll see what I have so far in psuedo-code:
Populate array @folders with list of directory of backup folder
Return number of entries in folder to $check
$check = (Returned value of total entries in @folders)
While ($check > 4) {
If (-M "$folders" > 4.0) {
Rmdir ($folder)
Repopulate array @folders with current list of folders
Return new number of entries in folder to $check } Else {
STOP
}
}
Any help or suggestions on how to go about doing this would be most appreciated.