FreeBSD 12.x: rsync a specific folder to my destination folder

as above

I think it's best explained with an example.

Code:
/mnt/source/source-folder
      -> sfolder1
      -> sfolder2
      -> sfolder3
      -> sfolder4

The "sfolder" contains 10s of folders and 100s of files inside them.

I want to copy "sfolder2 and its contents" to /mnt/destination/destination-folder.

I tried

rsync -nriv --stats --include "sfolder2" --exclude "*" /mnt/source/source-folder/ /mnt/destination/destination-folder/

rsync -nriv --stats --include "sfolder2*" --exclude "*" /mnt/source/source-folder/ /mnt/destination/destination-folder/

rsync -nriv --stats --include "*sfolder2*" --exclude "*" /mnt/source/source-folder/ /mnt/destination/destination-folder/


and in all cases, stats report that only the "sfolder2" folder was transferred and the 10s of folders and 100s of files inside "sfolder2" was ignored.

What am I doing wrong?

My real aim is to copy multiple folders (from my sample folder setup above, sfolder2 and sfolder4) from the source to my destination. I'm only using 1 folder for now while testing.

Thanks
 
Trailing slashes are quite important with rsync.

# This copies the sfolder2 directory and its contents to /mnt/destination/destination-folder/sfolder2
rsync -avr /mnt/source/source-folder/sfolder2 /mnt/destination/destination-folder/

# This copies the content of sfolder2 to /mnt/destination/destination-folder
rsync -avr /mnt/source/source-folder/sfolder2/ /mnt/destination/destination-folder
 
It's a pain in the arse having to remember the slash behaviour so this is an option too (mkdir first time only):

mkdir /mnt/destination/destination-folder/sfolder2
rsync -a /mnt/source/source-folder/sfolder2/. /mnt/destination/destination-folder/sfolder2/.


p.s. option 'r' isn't necessary, 'a' covers it. 'v' is just noise unless you're wanting to watch the output scroll past.
 
Back
Top