在c#中安排备份
我正在为一家公司用 C# 编写一个软件,旨在在 Windows 平台上运行。
我的要求之一是允许用户安排备份。
即,用户设定计算机自动备份数据库的时间。
在linux平台上我会使用crons但我在windows平台上有点迷失。我不希望软件本身被实际打开以供备份运行。我希望即使软件本身没有运行也能执行它。
我最好的选择是使用 Windows 调度程序或创建一个将在启动时运行的自定义服务。
谁能指出我如何真正实现这一目标?欢迎任何建设性的建议。
谢谢。
I am writing a software for a company in c# which is intended to run on windows platform.
One of my requirements is to allow the user to schedule back ups.
That is, the user will set a time where the database will be backed up automatically by the computer.
On the linux platform I would have use crons but I am a bit lost on the windows platform. I do not want the software itself to be actually opened for the back up to run. I want it to be carried out even if the software itself is not running.
My best bet is to use windows scheduler or create a custom service which will run at start up.
Can anyone point me to how to actually achieve this? Any constructive suggestions are welcomed.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有关信息,Windows“AT”命令有点类似于 cron。您可以从命令行获得帮助,因此:
我不一定推荐它用于数据库备份。创建 Windows 计划任务或备份 SQL Server 数据库,请使用 SQL Server 的内置计划程序。
For info the Windows "AT" command is somewhat similar to cron. You can get help from the command line thus:
I wouldn't necessarily recommend it for a db backup. Either create a Windows scheduled task, or to backup a SQL Server database, use SQL server's built in scheduler.
另一种选择是创建一个 Windows 服务来处理该任务。然后您可以快速轻松地编写所需的任何代码(例如备份/电子邮件日志等),并且它可以在您的应用程序运行时工作。
有多种方法可以使用 Windows 内置的任务计划程序来完成相同的任务,但这只是我更喜欢的替代方案。
Another alternative would be to create a windows service to handle the task. Then you could write any code needed (e.g. Backup / Email logs, etc) quickly and easily, and it would work w/o your application running.
There are ways to accomplish the same task with Task Scheduler built into windows, but just an alternative that I would prefer.