Rsync Question - back up all *contents* of a folder into another folder?

Is there a way to use rsync to copy all the contents of one folder into another folder, but not the folder itself? That is, if I have a bunch of stuff in Folder_A, I want to copy all that stuff into Folder_B, but directly into Folder_B, not into a folder inside Folder_B that is named "Folder_A". And I want to use Folder_B as a backup location, so a simple cp command won't do the trick; it should work with rsync or a similar tool.

Any ideas? Thank you in advance.

Not sure, maybe here in last post using rsync:

https://stackoverflow.com/questions/23693562/how-to-copy-all-of-the-files-from-one-directory-to-another-in-a-bash-script

Note not a user of rsync.

2 Likes

if you read the rsync man page, it explains placing a trailing / in the dest dir or not

rsync -av folderA/ folderB
v
rsync -av folderA/ folderB/

2 Likes

Actually, it would:

cp -a Folder_A/. Folder_B
2 Likes

@tkn Could that version be used to do updates of Folder_B based on what changed in Folder_A?

@pavlos_kairis Thank you, interesting to know!

@mendy Thank you, that seems to work!

3 Likes

Yes, by adding the -u (update) switch:

cp -au Folder_A/. Folder_B

'cp' has a lot of options. Check 'man cp'

4 Likes