To copy only hidden dot files and directories using rsync, use the --include option with a pattern to match hidden files, and the --exclude option with a pattern to exclude all other files:
rsync -av --include='.*/' --exclude='*' source_directory/ destination
Here’s what each option does:
-a(or--archive) is equivalent to-rlptgoDand preserves almost everything in the source directory, including symbolic links, permissions, timestamps, and owner and group information.--includespecifies a pattern to include. In this case,'.*/'matches any directory whose name starts with a dot (.).--excludespecifies a pattern to exclude. In this case,'*'matches all files and directories except those that match the include pattern.
Note that rsync is a versatile tool and you may need to adjust the options to suit your specific needs. For example, if you want to copy hidden files in the source directory but not hidden files in subdirectories, you would need to change the include pattern to '.*' and add another exclude pattern to exclude subdirectories.
(Provigil)