trusktr
trusktr

Reputation: 45504

Why does `rsync <...> /path/to/someDir /path/to/otherDir` leave me with `/path/to/otherDir/someDir`, not syncing files from `someDir` into `otherDir`?

Why is my rsync doing that? It's basically just making a copy of the someDir folder inside otherDir. If I run the command again after making changes in /path/to/someDir, rsync will sync all files from /path/to/someDir to /path/to/otherDir/someDir. How do I get all the files inside /path/to/someDir synced to /path/to/otherDir.

This is what the command looks like that I'm excuting:

rsync --stats --compress --recursive --times --perms --links --delete --exclude ".git" --exclude "wp-content/upload" --exclude "wp-content/uploads" --exclude "wp-content/gallery" /path/to/someDir /path/to/otherDir

Upvotes: 2

Views: 295

Answers (2)

Pablo Fernandez heelhook
Pablo Fernandez heelhook

Reputation: 12573

rsync is one of the few commands that make a distinction between /your/path and /your/path/

When you don't use the trailing backslash you are referring to the directory, while when you use it you are referring to the contents of the directory.

Try

rsync --stats --compress --recursive --times --perms --links --delete --exclude ".git" --exclude "wp-content/upload" --exclude "wp-content/uploads" --exclude "wp-content/gallery" /path/to/someDir/ /path/to/otherDir

That extra trailing slash in /path/to/someDir/ will make the contents of it available in /path/to/otherDir.

BTW: Don't be tempted to use /path/to/someDir/* as was suggested, that will give you problems when you have many files and it won't copy files with names beginning with ..

Upvotes: 3

hellork
hellork

Reputation: 420

The /path/to/someDir refers to the folder, someDir, not the files inside. If you want instead to copy the files out of /path/to/someDir, try this:

rsync... /path/to/someDir/ /path/to/otherDir

Upvotes: 2

Related Questions