Time Machine saves hourly backups for the past 24 hours, daily backups for the past month, and weekly backups for everything older than a month until the volume runs out of space. At that point, Time Machine deletes the oldest weekly backup (Time Machine).

I'm at the point where I already have the bash script (rsync) which makes backups every hour. The backups are folders named as "2015-01-01 08", where "08" is the hour.

At some point folders older than 24h need to be deleted. So I'm looking for this magic. I guess it will be kind of rm -R some_pattern. How would such a pattern look like?


You can use a 1-line command if running Linux (YMMV on OS X):

find /path/to/your/backups/ -type d -mtime +1 -exec rm -r "{}" \;

Note that this assumes your directories are not modified after creation.

You can omit the -exec rm -r "{}" \; part if you only want to output directory names to test the command.

  • To avoid that assumption, I would like to check the date from the name of the folder. – oqrxke Feb 2 '15 at 1:32
  • How to iterate over all the folders? – oqrxke Feb 2 '15 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.