EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Backup file on Write

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
Posted: 11/16/2010 01:14:40
by Oren Aviram (Basic support level)
Joined: 01/11/2009
Posts: 4


I want to create a process that whenever a user tries to save a file (a document), that is already exists on his machine, instead of overwriting the existing file, the process backs-up the old file in a different name, and save the new one as requested.

I tried doing this using Callbackfilter WriteC, got the filename when the user tries to write, but I was unable to rename it, or evern access it, cause it is already been captured by the original process.

Am I missing something?
Can I do it in other way?

Can I change the original filename?

Can I divert the saving file to a different location, or even store it in memory
instead of writing to storage?

Please advise.
Posted: 11/16/2010 02:18:00
by Vladimir Cherniga (EldoS Corp.)

renaming the file on the fly may be a big problem, but you may get access to the file for backup purposes keeping open handle obtained in Open/Create callback path. Look at the Encrypt sample for the details. Then in write callback you may save the modified data before they will be put on a disk, as you already have this byte range copied to your user space in write callback.
Also you may try to play with reparse rules to gain the desired results, may be by making a backup of the file on open request and redirecting user requests to the newly created backup.
Posted: 11/16/2010 12:51:09
by Oren Aviram (Basic support level)
Joined: 01/11/2009
Posts: 4

Hi Vladimir,

Thank you for your response.

Sorry for asking, although I have a general idea what the Encrypt sample suppose to do, I am not sure what and how it is really doing it.

can you direct me to documentation about this application?

Posted: 11/16/2010 13:10:12
by Eugene Mayevski (EldoS Corp.)

Samples are self-documenting i.e. the user is supposed to study the source code in order to find out how to do different things.

From your questions it's not clear what you are attempting to do. If you want to create some kind of extended recycle bin (though such applications with long history do exist on the market), then you need to understand first, when you are going to copy the data of the file, and then ask how to do this. So far you are asking about unrelated things not knowing exactly, what you want to get.

Sincerely yours
Eugene Mayevski
Posted: 11/16/2010 13:42:07
by Oren Aviram (Basic support level)
Joined: 01/11/2009
Posts: 4

Hi Eugene,

As for the Encrpt sample, I am still learning it. It looks like a lot of work was put in it. I ask for more documentation, just to get a better understaning, and not to an excuse to skip class.

As for my task, I want to make some kind of a backup for overwriten files, like when you write a document using WORD, and while writing it you save it over and over again, with every change. I want to make a process that backs it up automatically with every version saved, without having the need to "save it as..." every time you don't want to overwrite the previous file.

Let me be clear, the saving part should take place the moment the user click "save". It should be saved normaly, but with this action, another file is added to the folder, with a timestamp attach to the name, saying this is the previous file - the actuall one you opened, before making any changes.

If no changes been made to the file that was opened, or no save action took place, no file should be copied, anywhere (might be alot to store).

Hope this makes any sense :-)


Thanks for the
Posted: 11/16/2010 13:55:42
by Eugene Mayevski (EldoS Corp.)

You need to learn how Office works. It doesn't write anything to the data file. It creates a temporary file, writes everything there, then renames previous data file to some other file name, then renames the temporary file to the data file name, then removes old file. So tracking file writes won't help you. Now what you need to do is to track file rename operation and if this file rename moves away the data file by renaming it, then make a copy of it. If such rename operation didn't happen and the rename operation is going to overwrite the file, - again, make a copy of the file being overriden.

To open the file without filtering use OpenFile method of CallbackFilter class. The handle opened this way won't be subject to filtering and you won't go to the infinite loop.

Sincerely yours
Eugene Mayevski
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages



Topic viewed 3688 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!