How can I watch a file or folder for changes, and when any updates occur, back up a copy of that file?
For example, when c:\orders\orders.xml is created or updated, write a copy to orders.xml.yyyymmddhhmmss
How can I watch a file or folder for changes, and when any updates occur, back up a copy of that file?
For example, when c:\orders\orders.xml is created or updated, write a copy to orders.xml.yyyymmddhhmmss
Enable file system auditing for each and every event that you want this to trigger on. Then, create an event trigger with a script attached to it for each relevant event ID (this is insane, btw).
Or, you could just periodically use a regular backup tool like everyone else does. Plenty of vendors use snapshot-based continuous backup with 5 minute protection intervals now including DPM, Commvault, Falconstor, etc. A combination of that and volume shadow copies should get you file history and data protection.
If you are open to using a hosted service for this, Crashplan will watch files in real time and backup upon change:
http://support.code42.com/CrashPlan/Latest/CrashPlan_Glossary#real-time
Also gives you the added benefit of off site backup (assuming they meet the security) requirements of the data in question).
In addition to MDMarras event-id idea which clearly has something, I like running these as task scheduled perpetually running background jobs:
1) Running robocopy /mir on a folder with the /mon: and/or the /mot: options which turns robocopy into a continuous monitoring process. I do this on my office workstation for stuff that wouldn't end up in the serverside backup jobs otherwise, and to sync down local copies of things like installers which can be good to have at hand. I thought it would be a quick hack until I replaced it with something more robust, but it works so well I'll stick with it.
2) For monitoring text file content changes, one can use get-content with the -wait to keep a continuous watch and possibly also -tail option (to avoid parsing the entite file when the job is restarted). As changes are detected, actions can be triggered. This makes it possible to have logic such as file renames to include timestamps. I use this to monitor logs which works fine.
I use the task scheduler to launch at startup, then start the process every 5 mins but only allow one instance. This keeps the jobs always running but without spawning multiple identical processes.