简体   繁体   English

备份算法

[英]Backup Algorithm

I am looking at writing a program (.Net)for backing up files on a computer. 我正在寻找编写用于在计算机上备份文件的程序(.Net)。 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? 该算法的O符号是什么?

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() . 在.NET中,它是System.IO.FileAttributes.Archive ,可以与VB中的SetAttr一起使用,或者与System.IO.FileInfo.AttributesSystem.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. 因此复杂度将为O(n),其中n是文件数。

Here's a very good simple stuff I'm using for backups in my scripts: http://www.mikerubel.org/computers/rsync_snapshots/ . 这是我在脚本中用于备份的非常简单的好东西: 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. 除日期时间外,我还将保留文件大小并将其添加到比较中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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