views:

179

answers:

3

I am looking at writing a program (.Net)for backing up files on a computer. How would I go on about knowing what files have changed to backup (I don't really want to scan the last modified dates each time.

Are there any backup algorithms for backing up only the bits of a file have changed. What are the O notations for the algorithm?

+1  A: 

Could I suggest searching for 'rsync for windows' in your favourite search engine?

Keith Gaughan
A: 

Here's a very good simple stuff I'm using for backups in my scripts: http://www.mikerubel.org/computers/rsync_snapshots/.

Based on this, the first approach would be to build a database of file modification times and compare/update them each time you're making a backup copy. Apart of datetime, I would also keep file size and add it to the comparison.

Michal Rogozinski
+2  A: 

Check the archive bit out. It may be what you want.

In .NET it's System.IO.FileAttributes.Archive, which can be used with SetAttr in VB, or System.IO.FileInfo.Attributes or System.IO.File.SetAttributes().

Any algorithm that checks the last modified time or archive bit will depend on the number of directories on the drive. Since both attributes are stored in the directory, the timing will depend on the filesystem and its level of caching. A more efficient way to analyse backup efficiency may be to look at the number of blocks that have changed.

Mark