0

I want to copy new files from my NAS to my external hard drive. I did copy the new files manually up to this point. Now I want to use a script to automate this for me. However everything I tried so far with rsync seems to copy all files and not only the new files. I tried with the following command:

rsync -ar \
      --ignore-existing \
      --size-only \
      --progress --info=progress2 \
      --dry-run \
      "/Volumes/NAS" "/Volumes/G-DRIVE mobile SSD R-Series"

I also tried without size-only, with checksum etc. Can somebody explain the behaviour to me or what I need to do in order to complete my task? When printing stats it always shows that it would transfer all the files. Also with the -i parameter I get the following information for every file: >f++++++++++

3
  • Ok I quickly checked the metadata and found that the creation date is different f.e "kMDItemContentCreationDate = 2012-01-28 05:59:13 +0000" vs. "kMDItemFSCreationDate = 1970-01-01 00:00:00 +0000". However the size (kMDItemFSSize = 1170942) seems to be the same and I thought with the size-only option this should work.
    – dehlen
    Commented May 18, 2023 at 15:10
  • This worked fine for me.
    – Cyrus
    Commented May 18, 2023 at 22:28
  • 1
    Thanks I found the solution in the accepted answer from your link. I was missing a trailing slash in the source folder which was causing the problem :)
    – dehlen
    Commented May 19, 2023 at 6:35

1 Answer 1

3

The correct command should probably be this:

rsync --archive --progress --info=progress2 \
    '/Volumes/NAS/' '/Volumes/G-DRIVE mobile SSD R-Series'

The -a (--archive) flag implies -t (--times) and -r (--recursive) so you don't need to specify those explicitly. Using --size-only is a poor choice when you have size and timestamp available from using -a (--archive), but if you're copying to a limited filesystem such as FAT you may need a time window such as --modify-window=2 to overcome the two second time granularity. You shouldn't use --ignore-existing unless you want to ignore changes to the source files once you've got a copy of any sort on the destination.

Definitely use --dry-run (-n) while testing, but remember to remove it when you're ready for the rsync action to be applied.

Finally, the source directory should usually have a trailing slash. The documentation describes it like this,

A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .