Here's something you can try. Be very careful with it because it uses rm -Rf at one point.
Code:
#!/bin/bash
#set -x
BACKUP_DIR=/home/lyle/empty/backups
DELETE_AFTER_DAYS=14
(
if ! cd "$BACKUP_DIR" &> /dev/null
then
echo Could not change to $BACKUP_DIR. Exiting.
exit 1
fi
find -daystart -maxdepth 1 -type d -ctime +$DELETE_AFTER_DAYS -exec rm -Rf {} \;
)
I tested it with mtime in place of ctime in the find line because that's the only way I could test it short of creating one directory a day for 20 days and then testing it. I don't see a way to change the status change time with touch.
I use rdiff-backup; see
http://rdiff-backup.stanford.edu/. I have a year's worth of backups. My home directory (today) is 1.2GB, one years worth of backups is 4.3GB, so it's pretty effecient disk-space wise. I'd recommend using that instead of the above script.
Lyle