0
rsync -rv --include='index.js' --include='*/' \
                   --exclude='/node_modules/' \
                   --exclude='*' \
                   --prune-empty-dirs /www /testbackup -n

...some line in result..
www/proj-1/node_modules/xdg-basedir/index.js
www/proj-33/node_modules/somedir/index.js
...

rsync version 3.1.2

I just want to get all index.js files only outside node_modules directory, any suggestion please without using filelist.txt

1 Answers1

0

You may be able to do this using rsync alone, however I'd find it easier to do with find + rsync:

find /www -type f -not -path '/www/*/node_modules/*' -name 'index.js' -print0 |
    rsync --dry-run --files-from=- --from0 -v / /testbackup

Remove --dry-run if you're happy with the result.

Note: you're using -r instead of the "standard" -a; from that I gather you don't want to turn on all the options normally turned on by -a. So this command won't either.

% tree /www
/www
├── proj-1
│   └── index.js
├── proj-10
│   └── node_modules
│       └── index.js
├── proj-2
│   └── index.js
├── proj-3
│   └── index.js
├── proj-4
│   └── index.js
├── proj-5
│   └── index.js
├── proj-6
│   └── node_modules
│       └── index.js
├── proj-7
│   └── node_modules
│       └── index.js
├── proj-8
│   └── node_modules
│       └── index.js
└── proj-9
    └── node_modules
        └── index.js

16 directories, 10 files % find /www -type f -not -path '/www//node_modules/' -name 'index.js' -print0 | rsync --dry-run --files-from=- --from0 -v / target building file list ... done www/ www/proj-1/ www/proj-1/index.js www/proj-2/ www/proj-2/index.js www/proj-3/ www/proj-3/index.js www/proj-4/ www/proj-4/index.js www/proj-5/ www/proj-5/index.js

sent 292 bytes received 49 bytes 682,00 bytes/sec total size is 0 speedup is 0,00 (DRY RUN)

kos
  • 41,268