Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to create a directory public_html/archive that is a mirror of public_html/images, except that deletions in the images directory don't cause corresponding deletions in archive.

I was going to manage all of this in code, but then I figured, maybe the system can handle it for me in a robust way.

Note that the website will reference archive in real time, so it has to be an instant mirror and not something done nightly, etc.

Is this possible? Thanks!

share|improve this question
Are all the new images created by a single program or script? If so, modifying that code to write to both places might be the easiest solution. – coneslayer Feb 7 '11 at 17:04
This is probably the best solution for most people. :) However, 1) I am curious, and 2) The "script" is a CMS, so the event "file is being saved" is a little less straightforward and requires making sure all the right hooks are attended to. – feedbackloop Feb 7 '11 at 17:15
up vote 0 down vote accepted

rsnapshot or unison might work if you didn't need it realtime. A realtime solution would end up being somewhat like sparkleshare - using inotify to check for changes, and copying changed files somewhere.

share|improve this answer
Accepted for mentioning inotify, which led me here: which mentions inotify-tools. Thanks! – feedbackloop Feb 8 '11 at 19:58
yay for the scattergun approach. amusingly this might help solve a project i was plotting myself, which would involve inotify – Journeyman Geek Feb 9 '11 at 0:02

Using xcopy 's /D switch you can specify only files after [the day/time of last back up]. It sounds like you don't need to mirror so much as push new files into the archive.

For Linux, per the tag, you can run a find for files after [the day/time of last back up], the cp them to the destination directory (with something like $ find . \! -cnewer date_marker). You can dig into rsync and use the exclude tag for it as well, that might afford you more flexibility with directories.

share|improve this answer
Local rsync looks close to what I want, except that I want the syncing to happen automatically without invoking a command. As soon as my app creates a file in "images", I want it to create one in "archive". Like a symlink except the target ignores deletions in the source. – feedbackloop Feb 7 '11 at 16:54
Hm. I know you can use cron to run it hourly or whatever... but I'm guessing you want instantaneous hence why you said mirroring. – mfg Feb 7 '11 at 17:07

You must log in to answer this question.

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