4

I am trying the following command using rsync to copy only files that

  • are new
  • have a different size
rsync -niav --size-only   /home/me/source/Electronica  /media/externalDrive/dest/Electronica

However, this dry-run results in the following output:

>f+++++++++ Electronica/music/AlbumArt_{F0CB439F-A1FC-47DB-A698-C561191F3FDE}_Large.jpg
>f+++++++++ Electronica/music/AlbumArt_{F0CB439F-A1FC-47DB-A698-C561191F3FDE}_Small.jpg
>f+++++++++ Electronica/music/Folder.jpg

which I interpret to mean that those files are copied. But they have the same size! (The times and flags are different, though). Also the rsync refers to an external hard-drive (with a different format).

I also tried the following commands:

rsync -niav --size-only --ignore-times  /home/me/source  /media/else
rsync -niav --size-only --ignore-existing /home/me/source  /media/else

But still, these files are shown in the same way, meaning they would have copied. What else can I try?

And what is wrong with the main page description?

--size-only     skip files that match in size
  • >f+++++++++ indicates that the file (f) is copied (>) because it does not exist (+++++++++) on the remote side. Are you sure you're comparing the right paths (your current parameters will copy the content of source into else/source)? – n.st Jun 5 '16 at 16:45
  • I have updated the question to make it clear, the the last bit of the path I give to rysnc is the first bit of the path that is written out. I am not sure that is correct, but I am sure there is NOr directory /home/me/source/Electronica/Electronica. I interpret it that the files exist on both sides at the correct location... – Alex Jun 5 '16 at 16:50
  • If you've only run dry-runs so far, rsync will not have created /home/me/source/Electronica/Electronica, but will already check your source against its contents (of which there aren't any, of course). – n.st Jun 5 '16 at 17:03
8

You've fallen into rsync's classical "trailing slash trap":
If the source path does not end with a slash, rsync will copy the source directory. If you intend to copy the contents of the source directory, it needs to end with a slash.

Let's look at an example, assuming you want to copy a file at /home/me/source/Electronica/music/Folder.jpg:

rsync -a /home/me/source/Electronica  /media/externalDrive/dest/Electronica

will copy the Electronica directory from the source to the destination, so it will create /media/externalDrive/dest/Electronica/Electronica/music/ and put Folder.jpg in there.

rsync -a /home/me/source/Electronica/  /media/externalDrive/dest/Electronica

will copy the contents of the Electronica directory, so it will replicate the music directory under /media/externalDrive/dest/Electronica/ (if it doesn't exists) and Folder.jpg will end up at /media/externalDrive/dest/Electronica/music/Folder.jpg.


To make matters more confusing, it does not matter if the destination path ends with a slash.

Just make a habit of ending all rsync paths with a slash, then you'll be safe from any nasty surprises.

  • 1
    Yes, I JUST realized. Happens to me all the time... – Alex Jun 5 '16 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.