rsync backup *cache* directories and files

I’m creating a backup scheme with rsync.

It is pretty clear not to include these:
/var/tmp, /var/cache, /var/run

But cache is all over the place. The word cache seems to come in a variety of capitalization and concatenations. Considering just applying this rule under /home and /var.

But this would include:

I used the command below for poking around:
for f in $(find /var -iname “cache” ); do file “$f”; done


Thank you.

Why go to the trouble of excluding them? Just back them up as normal.

My reasoning was to improve:

  • Disk space
  • Network bandwidth

A lot of stuff gets saved on the user’s behalf for everyday, real-time performance, but not necessary for worst-case or daily backups. I was kind of using the fhs as a lead. A lot of apps seem to put tmp and cache in their own directory.

Thank you.

You could exclude the browser cache directories, but the rest are small beer.

You can also use a regex pattern in rsync exclude, but I hope you never have a wanted file with the letters “cache” somewhere in the name or it will not get backed up.