开发者

Linux: automatic backup on save of changed file

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开发者_StackOverflow中文版/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, 'keeper' which I have open-sourced on GitHub. Hope it will be useful to others.


  1. Use source control instead
  2. incron can monitor the filesystem and run commands on file change/create/delete/etc operations.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜