Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator: Only copy newer files / timestamp check

Hello everyone,


Recently I bought a Macbook Air. I've used Windows all my life so I find it pretty hard to get used to OSX.


I'm using a Synology NAS as backup solution. On my Windows PC, I wrote a Robocopy script that copies all my important data to my Synology, but only if the data is newer.


Now I want to use the same solution on OSX by using Automator. I'm able to copy all my files in 'Documents' to my Synology, but this copies everything everytime. I'm looking for a way to only copy files if they are newer.


The target location is: afp://diskstation.local/Home

The source location is: Documents


How can I do this? I've searched on the internet but found nothing that really helped me.


Greetz,

Jeroen

Posted on Aug 17, 2015 7:47 AM

Reply
Question marked as Best reply

Posted on Aug 18, 2015 4:35 AM

Consider using rsync. If you want to wrap it in Automator, use the Run Shell Script Action.

Try this in Terminal:

rsync -n -aEv "~/Documents/" "Tony@diskstation.local/Home"

[You need to replace Tony with the User on your destination]


Note: I used the -n ( —dry-run) flag to do a "trial run". If the report show that it works as intended, remove the -n flag



To see more rsync options, type man rsync in Terminal, or see:: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/rsync.1.html

6 replies
Question marked as Best reply

Aug 18, 2015 4:35 AM in response to JSD1985

Consider using rsync. If you want to wrap it in Automator, use the Run Shell Script Action.

Try this in Terminal:

rsync -n -aEv "~/Documents/" "Tony@diskstation.local/Home"

[You need to replace Tony with the User on your destination]


Note: I used the -n ( —dry-run) flag to do a "trial run". If the report show that it works as intended, remove the -n flag



To see more rsync options, type man rsync in Terminal, or see:: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/rsync.1.html

Aug 18, 2015 7:39 AM in response to JSD1985

You can also add additional directories (and files) to the source:

rsync -aEv "~/Documents/" "~/Desktop/" "Tony@diskstation.local/Home"

[Note: Use a trailing slash on the source 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"]

Also, if you don't want to copy all files (or Folders) in the source directory, see the —exclude and —include options.

Aug 26, 2015 5:23 AM in response to JSD1985

JSD1985 wrote:


What does the -aEv option do? Are these multiple options?


Good to see it worked. rsync is a great tool.

The -E option will copy extended attributes and resource forks.

The -a is the rsync "archive" option (same as same as -rlptgoD)

-v will show the progress in Terminal.


Not sure if you're copying to a FAT system, but if you are, look at the --modify-window option:

--modify-window

When comparing two timestamps, rsync treats the timestamps as being equal if they differ by no

more than the modify-window value. This is normally 0 (for an exact match), but you may find

it useful to set this to a larger value in some situations. In particular, when transferring

to or from an MS Windows FAT filesystem (which represents times with a 2-second resolution),

--modify-window=1 is useful (allowing times to differ by up to 1 second).

Automator: Only copy newer files / timestamp check

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.