|Don't ask to ask, just ask|
Re: Delete all but the most recent backup fileby Kenosis (Priest)
|on Jan 24, 2013 at 05:54 UTC||Need Help??|
If I'm understanding you correctly, perhaps the following will be helpful:
Output (the files that would be deleted):
If you populate @fileNames with the file names in the directory where the backups live, it will grep them only allowing backup-patterned files through. Then, using a Schwartzian transform, it sorts the backup file names in decending order and shifts off the first element (most recent backup file name) from @sortedFileNames. As it is now, the file names in @sortedFileNames are printed, but the unlink line can be uncommented, so all but the most recent backup files are deleted.
** Please thoroughly test and verify this on a copy of the backup directory before going live with it. **