0

I am trying to backup my home folder to an external drive with the following command:

rsync -acu --delete --exclude-from='/home/chh1/rsync_exclude.txt' /home/ /media/chh1/f86f92f7-bcb4-4b8e-8a64-8a210606d422/home_backup/

The --exclude-from= file

/home/chh1/rsync_exclude.txt

contains the following entries:

.cache
crewdb.bak.sql

I really want to exlude .cache but also .dconf which is contained within it as I want to exclude files that require root privileges and unnecessary .cache data contained in /home/chh1/.cache.

When I run

find ~ -name ".cache"

I get the following output:

/home/chh1/snap/pdfmixtool/common/.cache
/home/chh1/snap/gnome-system-monitor/common/.cache
/home/chh1/snap/okular/63/.cache
/home/chh1/snap/freemind/common/.cache
/home/chh1/.cache
find: ‘/home/chh1/.cache/dconf’: Permission denied

I really want to exclude

/home/chh1/.cache

which would take care of dconf and general .cache junk as well. However, I do not want to exclude the other .cache directories found when running the find command.

since --exclude-from= only matches patterns with what is in the exclude file, how can I specify a path rather than a pattern and preferably within the exclude file? Is there a way?

Thanks for your help it is indeed much appreciated!

0

Your exclude list can have absolute names too, that match beneath the starting directory, /home/ in your case. Use the line

/chh1/.cache

instead of .cache to only exclude /home/ /chh1/.cache, i.e. /home/chh1/.cache

1
  • Thanks meuh, that has solved the problem! – Christian Hick Oct 20 '19 at 2:44

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.