简体   繁体   English

Windows服务的备份算法

[英]Backup algorithm for windows service

I have to design a backup algorithm for some files used by a Windows Service and I already have some ideas, but I would like to hear the opinion of the wiser ones, in order to try and improve what I have in mind. 我必须为Windows服务使用的某些文件设计一种备份算法,我已经有了一些想法,但是我想听听明智者的意见,以便尝试改进我的想法。

The software that I am dealing with follows a client-server architecture. 我正在处理的软件遵循客户端-服务器体系结构。

  • On the server side, we have a Windows Service that performs some tasks such as monitoring folders, etc, and it has several xml configuration files (around 10). 服务器端,我们有一个Windows服务,它执行一些任务,例如监视文件夹等,并且它具有几个xml配置文件(大约10个)。 These are the files that I want to backup. 这些是我要备份的文件。

  • On the client side, the user has a graphical interface that allows him to modify these configuration files, although this shouldn't happen very often. 客户端,用户具有图形界面,该界面允许他修改这些配置文件,尽管这种情况不应该经常发生。 Communication with the server are made using WCF. 使用WCF与服务器进行通信。

So the config files might be modified remotely by the user, but the administrator might also modify them manually on the server (the windows service monitors these changes). 因此,用户可以远程修改配置文件,但管理员也可以在服务器上手动修改它们(Windows服务监视这些更改)。

And for the moment, this is what I have in mind for the backup algorithm (quite simple though): 现在,这就是我要考虑的备份算法(虽然非常简单):

  • When - backups will be performed in two situations: 何时 -将在两种情况下执行备份:

    • Periodically : a parallel thread on the server application will perform a copy of the configuration files every XXXX months/weeks/whatever (configurable parameter). 定期 :服务器应用程序上的并行线程将每隔XXXX个月/周/无论执行一次(可配置参数)执行一次配置文件副本。 This is, it does not perform the backup each time the files are modified by user action, but only when the client app is launched. 也就是说,它不会在每次通过用户操作修改文件时执行备份,而仅在启动客户端应用程序时执行。
    • Every time the user launches the client : every time the server detects that a user has launched the application, the server side will perform a backup. 每次用户启动客户端时 :每当服务器检测到用户已启动应用程序时,服务器端都会执行备份。
  • How : 如何

    • There will be a folder named Backup on the Program Data folder of the Windows Service. Windows服务的“程序数据”文件夹上将有一个名为“备份 ”的文件夹。 There, each time a backup is performed, a sub-folder named BackupYYYYMMDDHHmm will be created, containing all the concerned files. 在那里,每次执行备份时,都会创建一个名为BackupYYYYMMDDHHmm的子文件夹,其中包含所有相关文件。
    • Maintenance : Backup folders won't be kept forever. 维护 :备份文件夹不会永远保留。 Periodically, all of those older than XXXX weeks/months/year (configurable parameter) will be deleted. 会定期删除所有XXXX周/月/年(可配置参数)之前的内容。 Alternatively, I might only maintain N backup sub-folders (configurable parameter). 或者,我可能只维护N个备份子文件夹(可配置参数)。 I still haven't chosen an option, but I think I'll go for the first one. 我仍然没有选择一个选项,但是我想我会选择第一个。

So, this is it. 就是这样。 Comments are very welcome. 欢迎发表评论。 Thanks!! 谢谢!!

I think your design is viable. 我认为您的设计是可行的。 just a few comments: 只是一些评论:

  1. do you need to back up to a separate place other than the server? 您是否需要备份到服务器以外的其他位置? I don't feel it's safe to back up important data on same server, and I would rather back them up to a separate disk (perhaps a network location) 我认为在同一服务器上备份重要数据并不安全,我宁愿将它们备份到单独的磁盘(可能是网络位置)

  2. you need to implement the monitoring/backup/retention/etc. 您需要实施监视/备份/保留/等等。 by yourself, and it sounds complicated - how long do you wish to spend on this? 听起来很复杂-您希望花多长时间?

Personally i would use some simple trick to achieve the backup, for example, since the data are plain text files (xml format) and light, I might simply back them up to some source control system: make the folder a checkout of SVN (or some other means) and create a simple script that detects/checks in changes to SVN, and schedule the script to be executed once a few hours (or more often up to your needs, or can be triggered by your service/app on demand) - this way it eliminates the unnecessary copy of data (as it checks in changes only), and it's much more trackable as svn provides all the history. 就个人而言,我将使用一些简单的技巧来实现备份,例如,由于数据是纯文本文件(xml格式)且轻量,我可能会将它们备份到某个源代码控制系统:将文件夹设置为SVN签出(或其他方式),并创建一个简单的脚本来检测/检查SVN的更改,并安排脚本执行几个小时一次(或者更频繁地满足您的需要,或者可以根据需要由您的服务/应用触发) -通过这种方式,它消除了不必要的数据副本(因为它仅检查更改),并且由于svn提供了所有历史记录,因此它更具可追踪性。

hope above can help a bit... 希望以上可以有所帮助...

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

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