views:

13

answers:

1

Hello,

On a windows mobile unit, the software I'm working on relies on a sdf file as it's database. The platform that the software is targeted towards is "less than optimal" and hard resets every once and a while. In the far distant past we lost data. Now we close the database, and copy the SDF file to the SD card. If the unit gets hard reset, we restore the app (also on the sd card) and the database.

I'm not concerned about the restore (just yet). The problem we have now is that doing a "backup" takes a crazy amount of time because the SDF is 7+ megs and writing to the SD card is slow slow slow.

My boss suggested we create hashes of "chunks" of the file and then write to the destination file only when a compare of the hashes is !=.

So here's the question.
How would you test if a file is changed if you can only have one copy of the file and thus can't compare it with it's original.

I'm just shooting for a bit of brain storming.

A: 

Just store your hashes of your chunks somewhere. You don't need the "backup" copy to compare to if you know what your hashes are. Obviously this creates a chicken and egg problem for at least one hash, but copying a single "chunk" is a much smaller problem.

Your proposed approach will still have performance problems though, as hashing a large file isn't going to be a pretty operation on a slow CPU powered by a battery.

I assume you don't have the granular control to keep track of the parts of the file you modify, and then update just those sections when you need to do backup?

Paul McMillan
Nope.. This is perhaps the least organized database that I've ever seen (where not done on purpose). Primary keys are strings (ugg) and very little is normalized. There is no datetime stamp on anything. It is just ugly. The problem with the hash idea (and why I've come here) is what you've said, and if the file changes just a bit in the front and moves all the data by an offset of just one, then the hashes will not match up and all performance gains are gone.
baash05
If you've got reasonable control over the system (I know nothing about winmo development) I'd say your best bet might be to take a look at third party tools that do this sort of differential backup. It's a hard problem to solve from scratch. You might look at DAR for inspiration. http://dar.linux.free.fr/
Paul McMillan
I think tar and rsync also implement some form of differential/incremental file copying/backup.
Paul McMillan