I would like to use rsync to sync only folder between folder a and b
> rsync -zaSH --delete -vv --delete -f"+ f/" -f"- f/*" a/ b
sending incremental file list
[sender] showing directory f because of pattern f/
[sender] hiding file f/1.data because of pattern f/*
[sender] hiding file f/4.data because of pattern f/*
[sender] hiding file f/8.data because of pattern f/*
[sender] hiding file f/10.data because of pattern f/*
[sender] hiding file f/6.data because of pattern f/*
[sender] hiding file f/3.data because of pattern f/*
[sender] hiding file f/5.data because of pattern f/*
[sender] hiding file f/9.data because of pattern f/*
[sender] hiding file f/7.data because of pattern f/*
[sender] hiding file f/2.data because of pattern f/*
delta-transmission disabled for local transfer or --whole-file
f/
total: matches=0 hash_hits=0 false_alarms=0 data=0
sent 88 bytes received 90 bytes 356.00 bytes/sec
total size is 0 speedup is 0.00
> tree
.
├── a
│ └── f
│ ├── 10.data
│ ├── 1.data
│ ├── 2.data
│ ├── 3.data
│ ├── 4.data
│ ├── 5.data
│ ├── 6.data
│ ├── 7.data
│ ├── 8.data
│ └── 9.data
└── b
└── f
As can be seen from the verbose output, the files were still scanned. If there are millions of files in the folder that could take very long. Is there a way to achieve the same goal without scanning files? Thanks.
You can't stop it scanning the files directly inside a/f/
, but it shouldn't scan any subdirectories of those unless they are also called f
.
This command will exclude those too:
rsync -aSH --delete -vv --delete -f"+ /f/" -f"- /f/*" a/ b/
Prefixing patterns with /
means match the root of the source directory.
(I also removed -z
because compression makes no sense for local copies.)