views:

53

answers:

3

Is there any way/SW-tool that can be used to monitor a directory for changes to files and then either back it up to a unique file or to a version control system?

Reason: I'm using Code::Blocks and get carried away editing/testing/changing and occasionally (@#$%!) would want/need to revert/recover a previous bit of code. I want the backup to happen silently in the background, a setup and forget thing, until I need it. Ideally it must backup a file each time it is saved.

[edit 2010-09-29]

I've used Matthew Iselin's 2nd suggestion (incron) to create my own solution, 'simplebup' which I have open-sourced on GitHub. Hope it will be useful to others.

+2  A: 
  1. Use source control instead
  2. incron can monitor the filesystem and run commands on file change/create/delete/etc operations.
Matthew Iselin
Cool - I didn't know about it. Found inotify-cxx (with sample I can modify) that I can use to create my own solution. Thanks.
slashmais
+1  A: 

Hello,

there are kernel filesystem monitoring tools taht can trigger a programm when a file is modified (for example kfsmd or incron )

but i think a cronjob runnig every 5 minutes is enough isnt it?

well the questino is whats the best way do deal with your data then.

i can recommend rsnapshot which does incremental backups using hard links. so your disk usage will only increase when a file is modified or added and you can backup a whole directory.

or you can do an automatical svn commit (which is probably better)

in fact i think the simplest way for you would be a cronjob which checks in all changes using the svn command line tool.

Joe Hopfgartner
+1  A: 

I'm using Back In Time at home. It creates backups daily (you could configure it up to every 5 min) for each changed file, and creates hardlinks for each non-changed file pointing to the last full backup. This way, you always have complete directories. If you want, it automatically cleans up old backups and only keeps a few (one for each year, month, week for instance).

For programming, I would also suggest to use a source control.

Stefan Steinegger
nice idea, but I chop)
slashmais
symbolic links are ugly for that purpose ;) very big error potential. hardlinks are better!
Joe Hopfgartner
@Joe: yeah, you're right, the symbolic links are rubbish, they actually *do* hardlinks. Sorry, I'm not a Linux expert, just a casual user. Fixed it.
Stefan Steinegger