0

Following test structure:

src/
  one/
    one/
      file.txt
    two/
      file.txt
  two/
    file.txt

I only want to sync the file /one/two/file.txt.

I tried this but it does not work..

rsync -r --include='/one/two/file.txt' --exclude='*' src/ target/ 
Tobias Gaertner
  • 1,155
  • 12
  • 30

1 Answers1

0

Is there a reason you're using --include? If it's a single file then rsync /one/two/file.txt /target/ would work.

Have a look at this answer: How to RSYNC a single file?

If you're trying to send more than one file then you can use this, based on a pattern: Using Rsync include and exclude options to include directory and file by pattern

NoExpert
  • 376
  • 1
  • 2
  • 11
  • Yes, my example was a bit over simplified. I need to include certain files in an excluded part of the tree from a big rsync. Your linked question gave me the answer. Including all directorys first gives me what I need. rsync -r --include='/one' --include='*/two' --include='/one/two/file.txt' --exclude='*' src/ target/ Still if the nesting leven increases thats kind of ugly... – Tobias Gaertner Jun 22 '21 at 05:56
  • OK thanks. If you're answered the question, maybe mark this as resolved. – NoExpert Jun 23 '21 at 14:50