MSBuild 扩展包:验证备份远程
我正在尝试备份远程数据库服务器上的数据库,然后验证该备份文件。
备份工作正常,但当我尝试验证备份时,构建失败并出现错误:
DataFilePath not found: c:\DatabaseBackups\MyDB.bak
我在本地计算机上使用以下 xml 构建文件:
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TPath>C:\Program Files\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks</TPath>
<SqlInstance>myremoteserver</SqlInstance>
<ProductionBackup>c:\DatabaseBackups\MyDB.bak</ProductionBackup>
<SqlUserName>user</SqlUserName>
<SqlPassword>pass</SqlPassword>
<DatabaseName>MyDB</DatabaseName>
</PropertyGroup>
<Import Project="$(TPath)"/>
<Target Name="BackupDB">
<!-- Backup a database -->
<MSBuild.ExtensionPack.Sql2008.Database TaskAction="Backup" DatabaseItem="$(DatabaseName)" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath="$(ProductionBackup)"/>
<!-- Verify a database backup -->
<MSBuild.ExtensionPack.Sql2008.Database TaskAction="VerifyBackup" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath="$(ProductionBackup)"/>
</Target>
</Project>
如果我在本地计算机上运行备份和验证,则此构建文件工作正常,但在以下情况下失败:我将 MachineName 更改为远程服务器。 我相信在搜索备份文件时,MS Build 会在我的本地计算机上搜索,而不是在远程计算机上搜索。如何告诉 MS Build 在远程服务器上搜索备份文件?
I am trying to backup a database on a remote database server and then verify that backup file.
The backup works well but when I try to verify the backup the build fails with an error:
DataFilePath not found: c:\DatabaseBackups\MyDB.bak
I use the following xml build file on my local computer:
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TPath>C:\Program Files\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks</TPath>
<SqlInstance>myremoteserver</SqlInstance>
<ProductionBackup>c:\DatabaseBackups\MyDB.bak</ProductionBackup>
<SqlUserName>user</SqlUserName>
<SqlPassword>pass</SqlPassword>
<DatabaseName>MyDB</DatabaseName>
</PropertyGroup>
<Import Project="$(TPath)"/>
<Target Name="BackupDB">
<!-- Backup a database -->
<MSBuild.ExtensionPack.Sql2008.Database TaskAction="Backup" DatabaseItem="$(DatabaseName)" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath="$(ProductionBackup)"/>
<!-- Verify a database backup -->
<MSBuild.ExtensionPack.Sql2008.Database TaskAction="VerifyBackup" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath="$(ProductionBackup)"/>
</Target>
</Project>
This build file works fine if I run the backup and verification on my local machine but fails when I change the MachineName to a remote server.
I believe that when searching for the backup file MS Build searches on my local machine and not on the remote machine. How can I tell MS Build to search the remote server for the backup file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需提供文件路径作为 unc 路径即可。将目的地共享给您的用户,它应该可以正常工作。
如果您具有管理员权限:
否则将databaseBackups文件夹共享给您的用户:
Just provide the file path as a unc path. Make the destination shared to your user and it should work fine.
If youve admin rights:
Otherwise share the databaseBackups folder to your user: