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



## mrjayviper (Feb 2, 2021)

as above

I think it's best explained with an example.


```
/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


----------



## SirDice (Feb 2, 2021)

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`


----------



## tux2bsd (Mar 16, 2021)

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.


----------

