I usually just keep old backups, perhaps for some undefined historical purposes, but more likely just out of laziness. But clearly, this method (or lack thereof) can eat up disk space rather quickly.
I recently created a simple bash script that will find an remove all files or directories that are older than a specified number of days (as determined by modification dates). This helps keep Xobni’s backup directories small without having to manually go in there every few months, which is even more lazy-friendly. Awesome.
#!/bin/bash
# removes old directories to clear space
# 7 = number of days to keep directories/filesfind /var/backup/ -type d -mtime +7 -exec rm {} -R \;
find /var/backup/something -type d -mtime +7 -exec rm {} -R \;
I have this script running via cron every week and it works like a charm.
Posted on August 12th, 2008 by plusbryan
Filed under: Development

Leave a Reply