Score:0

rsync exclude file what given from a find command

gh flag

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.

Score:1
uz flag
Jos

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.

nobody avatar
gh flag
thank's. could adapt to my situation.
hr flag
You *could* do it in a single step I think - with `--exclude-from=-` to read the list of patterns from standard input - something like `find "$HOME" -not -user "$USER" -print0 | rsync someotption -0 -exclude-from=- ...`
uz flag
Jos
@steeldriver I agree that you could, and +1 for pointing that out, but I didn't feel like testing this, and doing it in two commands should be less error-prone.
nobody avatar
gh flag
my skript is running as systemd --user service `rsync -aAXEPos --ignore-existing --progress --verbose \ --exclude-from=exclude-rsync-bereinigt /home/alex/ /media/alex/bionic-home/alex/ `
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.