- bocDotNet –
A Windows service that
automatically backups files when they change.
So what’s all about this ?
The idea is to make backups from all changing files to have some kind of “go back” function.
First I planned to implement it on my Linux/Samba based system but ran into a technical limitation that stopped me. (Meanwhile I see a solution for this issue, maybe I will implement it when I’ll find some free time.)
For curiosity I checked what Windows offers for scenarios like that. One line of code come to the other and soon the mock-up had nearly all functions I needed, so here we are with a piece of software that does backups on defined folders.
It’s main purpose was planned for use on shared folders on a server but you can run it on your workstation too.
So what platform do I need ?
It will run on XP, Server 2003, Server 2008, Windows 7. Vista wasn’t tested but I guess it will work.
Except the operating
system, all you need is the DotNet framework version
2 installed on the machine. (You can get it from the Microsoft download
How do I get it running ?
Just run the setup, it will install the service, and run’s it. It will automatically set to start on the system boot. It will create shortcuts for the service handling in the start menu.
If you want to unregister, restart or register the service, just use the shortcuts.
Without any configuration the service has pretty nothing to do. You have to setup the folders and file types the service should observe. This is done using the bocConfig tool.
This is my configuration for my folder c:\documents:
So what are all those options ?
Using the configuration tool you can add/modify/remove folders the service will observe using the buttons in the toolbar. (They are pretty self explaining ;) ).
For each folder you can define the path, if subfolders should watched too.
The ignore patterns are
very essential because on based on this settings the incoming events are sorted
out to figure out if this file modification has to be backupped.
(Think on server scenarios where you have a few hundred subfolders, there will occur a lot of write events that have to be handled, so setting up an ignore pattern will highly reduce the load of this service.)
In my experience (especially for office documents) it’s a good idea to set the tilde sign as a prefix and the .tmp and ~ as a postfix. You can add multiple values by separate them by comma. On the “Backup settings” you can define the file extension to backup and the name of the backup folder where the backup should be stored. If the folder does not exist in this folder, this is a sign to the service that no backup should be created for tis folder. For scenarios where you need to have this folder and suppress backups, just place a file called “.noBackup” in the folder and bocDotNet will ignore this folder.
In the “Extra settings” you can limit the number of backups to keep where 0 means no limit. (I hope you have plenty hard disk space…) The buffersize is something that defines how much memory should be used to create a queue to store events from the filesystem. I wanted to make this configurable. On the internet I’ve read 4096 is a value that other people successfully used. (Within the service the value is multiplied by 16).
Please have in mind this is that kind of memory that can not swapped, (MS calls it “expensive memory”), so you might have to reduce it if your server runs low on memory.
After doing your changes
and saving them you have to restart the service by using shortcut from the
start menu. (It’s wanted to not automatically restart the service on config changes. Maybe you don’t want to restart the service
now because your users accessing the server and plan to schedule a task for
If everything went fine you are ready to do a test. Create a file and save it to the location.
Three seconds later you should find the backup in the backup folder. The three second pause was added to give the application the chance to close the exclusive write handle to the file, what would let the copy process fail.
How does it all work ?
Within the program folder a spool folder will be created where all write events that pass the ignore filter will create a job file within a folder for each watching directory. The service will run an external process that does the actual copy process and will clear the spool folder after processing it.
Are there any know issues ?
A big issue is logging, since I don’t have a concept for it. (Recommendations welcome !) Think how many events could occur, we can’t log that to the systems log. (I talk about a huge amount of log entry!) I experience some problems with floating the systems log, so I did not implemented that. Currently the only logging you can get is by adding a file called “DoLogging” in the spool subfolder. If present, all spool data will be held and any occurring error will be appended to the spool file for checking.
Use this with care, it could float your hard drive !
Why do I see the UAC so frequently ?
Because you are modifying system files! Unfortunately I decided to store the config file within the programs folder, so the UAC is still showing up when changing the configuration. (Maybe I will fix this in a future release. For now just blame it on me ;) )
What if I found a bug ?
Please file any found bug on the source forge tracker
What? No SRS or System Design document this time ? (Are you nuts ?)
Sorry, not this time, this started as a mock-up and was mostly planned on 5 pages of hand drawn flow charts on paper.
Furthermore currently I don’t find the time to write it. Sorry !
Can I have a poke this
Yes, but only for use on C64:
bocDotNet is licensed under the GPL v3 or later
Where can I download it ?
Downloads can be found here: https://sourceforge.net/projects/bocdotnet/files/
Where is the sourceforge project page ?
How do you created the
I used Easysetup that can currently (2011-10-25 21:57) be found here:
Initial release (Beta 1)
Windows, Visual Studio, XP, C# & .NET are registered trademarks of Microsoft Corporation in the United States and other countries. (http://www.microsoft.com)