I’ve searched all over the internet and everybody suggests the same thing - that adding --exclude=´.*´ should exclude hidden files and folders from an rsync. It doesn’t. I´ve also tried adding a slash and/or double quotes eg. --exclude=¨\.*¨ Nothing seems to work. AGH!! Would really appreciate some help.
Asked
Active
Viewed 1e+01k times
64
user289455
- 897
- 2
- 9
- 14
5 Answers
119
Both versions you are showing are wrong. You need to use double quotes. The following works and excludes hidden files and directories:
--exclude=".*"
If you only want to exclude hidden directories:
--exclude=".*/"
BeastOfCaerbannog
- 16,703
Rinzwind
- 309,379
8
I use this expression: --exclude=".[!.]*"
Does the job well for me excluding hidden files and directories.
kenorb
- 10,944
jonathanbell
- 183
1
This is the rsync command I use to make a copy of my local Dropbox folder, from my MacBook (MacOS) to an external network drive (mounted as extdisk below).
rsync -atv --delete --delete-excluded --exclude "DontCopyThisFolder" --exclude=".*" "/Users/admin/Dropbox/" "/Volumes/extdisk/Files/Dropbox/"
It uses the options:
- archive
- perserve times (on files & folders)
- verbose progress output (to see what is going on)
- delete and delete-excluded will remove all files from the destination that are not included in the list of files to copy. This also removes files that might have been copied by other means, but now isn't, because of the exclude "DontCopyThisFolder"-option, or the exclude=".*"-option that will exclude files starting with a dot.
Further documentation and options can be found at the rsync Man Page