Excluding trash in tar backup
I am using Debian, and I'm backing up my entire file structure to one tar file. I would like to exclude files that I have already deleted and are in the trash. However, this is proving difficult, since the trash files appear to be spread out all over the file system.
More specifically, the command I am using is:
tar zcvpf <target file> --one-file-system --exclude=home/patrick/MyBackups --exclude=mnt --exclude=proc --exclude=sys --exclude=dev/pts --exclude=root/.local/share/Trash / 2> <log file>
This, of course, excludes the folder with root trash, but there are plenty of other folders that appear to contain trash, which I learned when I went to root and entered the command "find -iname "*trash*" and got something like 100 folders with the name "trash" in them. In particular, I know that there are separate trash folders for each user (which, in my case, is only one user, myself, other than root).
For obvious reasons, I don't want to waste disk space backing up trash, which recently I noticed was adding an extra 5 GB to the backup file size and swelling it from 1.5 GB to 6.5 GB (since I had recently deleted some large files).
Therefore, I'm wondering if anyone knows of a way to exclude all the trash folders with a single option in the tar command? (Of course, I don't want to be over-inclusive in my exclusions, as maybe there's a legitmate, non-deleted folder that has the word "trash" in its name).
Any ideas?
Last edited by dilettante9; 07-07-2012 at 04:00 PM.
|