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'd like to have a simple, script-like backup solution to synchronize 2 local directories which provides a "fail-safe"-mechanism allowing to undo 1 commited unwanted modification of a file that got synchronized.

Let's say I have 2 local directories d1 and d2 initially containing the exact same files.

Is it possible to use a version control system to synchronize any changes from d1 to d2 like this:

1. a file f1 in d1 gets modified

2. d1 is synchronized to d2

3. f1 in d1 gets modified again

4. d1 is synchronized to d2 again

5. the initial version of f1 gets deleted in both directories, so that only the current and the second latest version of the file remain in both directories/repositories (an undo is possible and disk space is saved)

Also, this is on Linux (Arch).

Thank you in advance for your expertise!

share|improve this question

migrated from Aug 20 '12 at 14:49

This question came from our site for professional and enthusiast programmers.

First of all, this really does belong on Superuser, there is nothing programming related in this at all. Secondly, I would suggest RSYNC for keeping directories synced. – sosborn Aug 20 '12 at 2:24
RSYNC doesn't provide undo, does it? – MCH Aug 20 '12 at 2:28
Not sure if this will fit your requirements, but it is a good read anyway: – sosborn Aug 20 '12 at 2:48
Thank you for that link! Seems like an excellent read indeed! I'm currently diving in :) – MCH Aug 20 '12 at 2:57
This is on SuperUser because this is a question about using software, not building it. Git is a developer's tool, but it is not being used for development (Or, not in any way that makes that important) here. SU is the place for this question. There's plenty of knowledge on SU, however--it's not like the two communities are segregated, either. I'm not sure you want git here, anyway. rsync and copying changed files to either a third location or just a .bak or something would fit your specifications. If you need them to be always identical forever, though... why not just use a symbolic link? – Phoshi Aug 20 '12 at 23:43

Just set up git in your directory and remember to commit any relevant changes. You can recover earlier versions from there. To assuage lurking paraoia, set up a repository elsewhere (another machine!) to push your updates there.

share|improve this answer

You must log in to answer this question.

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