2021年8月18日 星期三

[rsync, copy] How to copy all files recursively from remote source to the local but exclude all {'*.pdf','*.log','*.json','*.jpeg','node_modules'} files

Command

rsync -av -e ssh --exclude={'*.pdf','*.log','*.json','*.jpeg','node_modules'}  Source-User@SourceHost:SourceFolder DestinationFolder


Example

rsync -av -e ssh --exclude={'*.pdf','*.log','*.json','*.jpeg','node_modules'}  jing@HOST-A:~/A-folder/ .


Where,

-a: Recurse into directories

-v: Verbose output

-e: Use ssh for remote shell so everything gets encrypted

--exclude: exclude files matching PATTERN



Reference

https://linuxize.com/post/how-to-exclude-files-and-directories-with-rsync/