Exclude hidden folders using rsync, but Include specific hidden folders and include all hidden files
There are a lot of posts about rsync
exclude being particular, I know, and I've spent some time digging myself for a solution, but thought it more expedient to defer to community mind power, which I'm sure can point me in the right track within seconds.
I'm copying many different users' home directories, but for reasons not relevant at the moment, need to basically eliminate a lot of differing confs, and because each user differs a lot, I want to write a rsync
line that can be run in any home folder for a user that excludes all hidden folders (except .ssh and .mozilla if applicable) but still captures hidden files in the home folder such as .bash_history, .profile etc.
Including the .ssh and other specified folders is important at the moment as other common folders could/should be added to that list at a later date. But for now, I need to basically exclude all hidden folders unless otherwise specified.
This is what I thought would work, but it sadly doesn't:
$ rsync -vahP --delete-before --include="*" --include={".ssh/",".mozilla/"} exclude=".*/" ./ /mount/anotherdisk/username/
What am I doing wrong?
It works for me if I remove option --include="*"
and add the forgotten dashes to the --exclude
option like:
rsync -vahP --delete-before --include={'.ssh/','.mozilla/'} --exclude='.*/' /home/username/ /mount/anotherdisk/username