编写日志传送自动化脚本
是否可以编写所有日志传送配置的脚本?
例如:我需要编写一个作业,启动从服务器 A 到服务器 B 的两个数据库的日志传送。
该作业将在服务器 A 上运行。
顺便说一下,两者都是 SQL 2008 R2 Enterprise。
服务器A上有一个共享。 \serverA\Log
我相信这就是所需要的。 是否可以仅通过脚本来完成? 我是否必须初始化数据库,或者是否有像 SSMS 这样的选项来自动初始化?
我必须手动创建职位吗?或者它的配置方式是否可以创造就业机会并对其进行管理?
它可以编写脚本吗?有人做过这样的事吗? 有人有一个脚本可以做到这一点吗?
提前致谢。
Is it possible to script All of the Log Shipping configuration?
For example: I need to write a job that initiates Log Shipping from two databases from server A to server B.
The job will run on Server A.
By the way both are SQL 2008 R2 Enterprise.
There's a share on server A.
\serverA\Log
I Believe this is all that is needed.
Is it possible to do it just by script?
Do I have to initialize the databases or is there a option like SSMS to auto initialize?
Will I have to create the jobs manually? or is it configured in a way that creates the jobs and manages them?
Is it scriptable? Has anyone done anything like this?
Does any one have a script to do this?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是完全可能的,并且可以通过日志传送设置 GUI 编写脚本。它生成的脚本中需要克服的唯一障碍将需要在同一脚本中连接到主数据库和辅助数据库。这可以通过使用 SQLCMD 的 SQLCMD 模式命令(使用 CONNECT 命令)来完成,确保在连接之间放置 GO。作为奖励,您还可以执行操作系统命令(复制、删除等),以便您也可以编写备份和恢复脚本。请参阅下面的示例。
This is totally possible, and it can be scripted out through the log shipping setup GUI. The only obstacle to overcome in the script that it generates will need to connect to both the primary and the secondary in the same script. This can be accomplished by used the SQLCMD mode commands of SQLCMD using the CONNECT command, making sure to put GOs between the connections. As a bonus you can also execute OS commands (copy, del, etc.) so you can script out the backup and restore as well. See example below.