tags:

views:

21

answers:

1

I am attempting to mirror a directory on a remote server using rsync. However, I would like a copy of all newly created files to be stored in a separate directory on the local machine.

For example, if a new file is added on the remote server, I would like it to mirror regularly (for example, to ~/mirror), but save an additional copy of only the new file in another folder, (for example, ~/staging). To be clear, only the new files should appear in staging.

My first approach was to allow rsync to update the timestamps, and then use that to make a copy. However, I would now like to preserve timestamps.

Can anyone provide ideas on a simple approach? I am open to use of additional utilities other than rsync.

A: 

You might consider making hardlinks in the extra directory.

ln --force --target-directory=~/staging ~/mirror/*

Edit:

If this is a Linux system, incron will trigger on inotify events and would allow you to make copies of files as they are added to a directory you specify.

Dennis Williamson
Thanks for the reply. I am specifically looking for only the new files to be copied to the ~/staging directory. Hard-linking everything would cause all files to appear in the staging directory.I have updated my description to make this more clear.
izakage