rsync exclude file what given from a find command
OS=lubuntu 20.04. I will upgrade to 22.04 (is not the question) I want to backup my $HOME, but there are some files that belongs not to my user
Is it possible to give rsync the output from find and let him exclude that?
My lack on english:
find $HOME -not -user $USER
/home/alex/initrd.img-5.3.0-53-generic
/home/alex/backup/restricted.pref
skip
Can I give it somehow in this form to rsync? Like from a file?
rsync someoption --exclude /path/to my exclude file
Not I know how to exclude files and folders but I'm a bit lazzy to change my backup-skript for that if it is not necessary.
You can do it in two steps, by redirecting the output of find
to a file:
find $HOME -not -user $USER > myExcludeFiles
rsync someoption --exclude-from=myExcludeFiles
From man rsync
:
--exclude-from=FILE read exclude patterns from FILE
Use the full path name to myExcludeFiles
when running from cron
.