简体   繁体   中英

Backup Algorithm

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?

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.

我可以建议在您喜欢的搜索引擎中搜索“ rsync for windows”吗?

You won't escape scanning all files, but that is limited to reading the directory sectors. Still takes a while for an average drive. Aside from the file-date there is an Archive bit on every file entry. Don't forget to clear that after backing up a file.

So the complexity will be O(n), where n is the number of files.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM