创建 Sql Server 数据库夜间复制的最佳方法
我想创造一份每晚都运行的工作。我有一个数据库 (MyDatabase),我想用它复制/替换我的临时数据库 (MyDatabase_Stage)。
我认为最简单的方法是做一些与 SQL Server Agent 相关的事情,但我以前从未做过这样的事情。进行此设置和测试的最佳实践和最简单的途径是什么?
我不在乎数据是否是 24 小时前的,最重要的标准是每晚同时进行完整复制。
I want to create a job that runs every night. I have a database (MyDatabase) that I want to copy/replace my staging database with (MyDatabase_Stage).
I presume the easiest way is to do something related to SQL Server Agent, but I have never done anything like this before. What is the best practice and easiest route to go to get this setup and tested?
I do not care if the data is 24 hours old and the most important criteria is that is does a full copy every night at the same time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 .bak 文件复制到临时服务器并使用脚本从那里恢复。
在代理作业中按计划运行脚本。
脚本的好处是您可以稍后添加功能 - 例如,您可能不需要审计表,并且这些表可以被截断。
copy the .bak file to your staging server and restore from there using a script.
Run the script on a schedule in an agent job.
The benefit of a script is that you can add functionality later - for instance you might not require audit tables and these can be truncated.
查看快照复制。作为设置的一部分,它将创建一个 SQL 代理作业来执行数据复制等操作。然后,您可以按照自己喜欢的时间和频率安排该工作。
Check out snapshot replication. As part of the setup, it'll create a SQL Agent job to do the copy of the data and whatnot. You can then schedule that job at whatever time and frequency you like.