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?
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:
<MSBuild.ExtensionPack.Sql2008.Database TaskAction="VerifyBackup" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath="\\$(SQLInstance)\C$\DatabaseBackups\MyDB.bak"/>
Otherwise share the databaseBackups folder to your user:
<MSBuild.ExtensionPack.Sql2008.Database TaskAction="VerifyBackup" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath="\\$(SQLInstance)\DatabaseBackups\MyDB.bak"/>
Related
I want to publish my dacpac file using VSTS. I will be giving only DACPAC file to Dev ops team. I want to ignore drop table that is not in source. If i Publish it from SSDT, I can change in advanced settings. How to do that for VSTS. I can see an option under debug menu, But I am unable to check that option, Screen shot is attached in below URL.
https://i.stack.imgur.com/TBQPe.png
You can give publish.xml along side your dacpac and include a similar setting in that xml as well such as mentioned below
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
<TargetDatabaseName>dbname</TargetDatabaseName>
<DeployScriptFileName>dbname.sql</DeployScriptFileName>
<TargetConnectionString>Data Source=<name>;Integrated Security=True;Persist
Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect
Timeout=60;Encrypt=False;TrustServerCertificate=True</TargetConnectionString>
<BlockOnPossibleDataLoss>False</BlockOnPossibleDataLoss>
<DropObjectsNotInSource>False</DropObjectsNotInSource>
<ProfileVersionNumber>1</ProfileVersionNumber>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
</Project>
and while deploying dacpac (using cmd or powershell) you need to pass this xml file path in /Profile: parameter to pick this xml for deployment settings
I am trying to restore sql server database from .bak file(database backup file) using wix installer 3.9. But Unfortunately its not happening. Here is my trial codes
<Fragment>
<Binary Id="PHRBackupBin" SourceFile="Database/PHR.bak"></Binary>
<!--<util:User Id="SQLUserSA" Name="[DB_USER]" Password="[DB_PASSWORD]"></util:User>-->
<util:User Id="SQLUserSA" Name="sa" Password="sa"></util:User>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="SqlComponent" Guid="8A1C82DB-1DD3-4FB5-8600-4F370FE1E04B">
<Condition>NOT Installed</Condition>
<sql:SqlDatabase Id="SqlServerDatabase" Database="PHR" Server="." CreateOnInstall="yes" DropOnUninstall="yes" User="SQLUserSA" ContinueOnError="no" Instance="SQLEXPRESS">
<sql:SqlScript Id="PHRBackup" ExecuteOnInstall="yes" ExecuteOnUninstall="no" BinaryKey="PHRBackupBin" ContinueOnError="no" />
</sql:SqlDatabase>
<CreateFolder/>
</Component>
</DirectoryRef>
<ComponentGroup Id="DatabaseConfiguration">
<ComponentRef Id="SqlComponent"></ComponentRef>
</ComponentGroup>
The above installer runs successfully if I replace the file with .sql(sql script) file. I also tried writing a script file to restore the database but no luck. May I ask the community how to run a .bak file from the wix installer.
Thanks in advance
Unfortunately, you won't be able to restore it using the bak file. This is not a script (which is required for the sql:SqlScript component), this is a backup file which is different.
A .bak file is usually the native backup file created in SQL Server.
A .sql file is a script, and could even be a mySQL dump which when run would seem like a restore although technically it would be creating a new db.
This is confirmed in the wix documentation: http://wixtoolset.org/documentation/manual/v3/xsd/sql/sqlscript.html
I have SSRS 2012 native mode. I can run Report Builder from localhost where SSRS is installed.
I am unable to run Report Builder from other machines, and I am getting such error:
Downloading http//10.149.100.*/ReportServer/ReportBuilder/ReportBuilder_3_0_0_0.application did not succeed.
The remote server returned an error: (401) Unauthorized.
Here is my scenario:
SSRS is installed on a server which is in a workgroup. There is local user on that server, ie. ruser.
I am accessing report manager from other computer which is in other workgroup/domain using address http//ssrs_server/Reports and I am passing ruser login and password. I can run every report in such way.
But I can't run Report Builder using button in the report manager.
I already tried this instruction http://msdn.microsoft.com/en-us/library/8faf2938-b71b-4e61-a172-46da2209ff55%28v=sql.110%29
and I set Basic Authentication with anonymous access to report builder.
Specifically I performed all steps from 1 to 6 in the section Enabling Anonymous Access to Report Builder Application Files.
The only result was that after I clicked on Report Builder button I received HTTP 500 error instead of HTTP 401.
Then I found out that I can place Report Builder installation files on the IIS and set custom url to the Report Builder. I did it and I could finally run report builder from other machine.
The only problem is that when the Report Builder is run from custom IIS URL then it doesn't connect to report server automatically.
However it is connecting automatically when it is run from default SSRS link.
What I want to achieve is:
either make the Report Builder to be runnable from default SSRS link
either make the Report Builder to be runnable from a custom IIS link (already did it) but also make it automatically connecting to report server.
I found the solution.
The first step is to enable Basic Authentication using this instruction: http://msdn.microsoft.com/en-us/library/8faf2938-b71b-4e61-a172-46da2209ff55%28v=sql.110%29
But I omitted step 4.
Next I used this instruction: https://support.microsoft.com/kb/955809?wa=wsignin1.0
and performed Method 3 - Create an explicit Web.config file
The web.config file need to be saved at this location: C:\Program Files\Microsoft SQL Server\MSRS11.ATC\Reporting Services\ReportServer\ReportBuilder
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation tempDirectory="C:\Program Files\Microsoft SQL Server\MSRS11.ATC\Reporting Services\RSTempFiles\"/>
</system.web>
</configuration>
Because ReportingService is use Windows Authentication .
so you can't use IP Address to link your ReportServer.
i will suggestion use Active Directory Environment in ReportingService.
if you use a normal workgroup. you can try this
1.modify hosts file in C:\Windows\System32\drivers\etc .
map hostnames to IP . Like: win-4mheefkokk4 192.168.179.5
2.change your ReportBuilder URL
From
http: //192.168.179.5/ReportServer/ReportBuilder/ReportBuilder_3_0_0_0.application
To
http:// win-4mheefkokk4/ReportServer/ReportBuilder/ReportBuilder_3_0_0_0.application
Then you can install ReportBuilder by ClickOnce mode. Hope it's can help you :)
The solution to SSRS 2012 - step by step IoI.
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2012/cc281309(v=sql.110)?redirectedfrom=MSDN
1 - Verify the report server is configured for Basic authentication by checking the authentication settings in the RSReportServer.config file, below the example:
C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\rsreportserver.config
<Authentication>
<AuthenticationTypes>
<RSWindowsBasic>
<LogonMethod>3</LogonMethod>
<Realm></Realm>
<DefaultDomain></DefaultDomain>
</RSWindowsBasic>
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
<RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>
2 - Create a BIN folder under the ReportBuilder folder. By default, this folder is located at \Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\ReportBuilder.
3 - Copy the following assemblies from the ReportServer\Bin (C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin) folder
to the ReportBuilder\BIN (C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\ReportingServices\ReportServer\ReportBuilder\bin) folder:
Microsoft.ReportingServices.Diagnostics.dll
Microsoft.ReportingServices.Interfaces.dll
ReportingServicesAppDomainManager.dll
RSHttpRuntime.dll
4- create a Web.config file to process Report Builder requests under an Anonymous account:
C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\ReportBuilder\Web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authentication mode="Windows" />
<identity impersonate="true "/>
</system.web>
</configuration>
Authentication mode must be set to Windows if you include a Web.config file.
Identity impersonate can be True or False.
Set it to False if you do not want ASP.NET to read the security token. The request will run in the security context of the Report Server service.
Set it to True if you want ASP.NET to read the security token from the host layer. If you set it to True, you must also specify userName and password to designate an Anonymous account. The credentials you specify will determine the security context under which the request is issued.
5 - Save the Web.config file to the ReportBuilder\bin folder.
6 - Open RSReportServer.config file (C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\rsreportserver.config), in the Services section, find IsReportManagerEnabled and add the following setting below it:
<IsReportManagerEnabled>True</IsReportManagerEnabled>
<IsReportBuilderAnonymousAccessEnabled>True</IsReportBuilderAnonymousAccessEnabled>
7 - Save RSReportServer.config and close the file.
8 - Restart the report server.
Mmm. I put the postgre jar on the lib folder of hsql database manager but then I tried to use the database manager an error occurs "java.lang.ClassNotFoundException:org.postgresql.Driver".
It is not enough to put the jar in the lib folder. You need to include the jar in the command line that you use to execute DatabaseManager. An example for Windows below:
java -cp /path/to/hsqldb.jar;/path/to/postgres/pg.jdbc3.jar org.hsqldb.util.DatabaseManagerSwing
I have an SQL database project in VisualStudio 2010 in source control with TFS 2010 with a few branches that each deploy to different servers depending on the configuration profile.
Using a sqlcmdvars file with the configuration profile appended in the filename (Debug.sqlcmdvars, etc..) for each configuration profile lets me specify the unique file path for a particular deployment environment by use of the reserved names Path1 and Path2 for the mdf file and the log file.
<?xml version="1.0" encoding="utf-8"?>
<SqlCommandVariables xmlns="urn:Microsoft.VisualStudio.Data.Schema.Package.SqlCmdVars">
<Version>1.0</Version>
<Properties>
<Property>
<PropertyName>Path1</PropertyName>
<PropertyValue>C:\SQLSERVER LOG\$(DatabaseName)\</PropertyValue>
</Property>
<Property>
<PropertyName>Path2</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\</PropertyValue>
</Property>
</Properties>
</SqlCommandVariables>
Now I'm trying to add a custom FileStream file with an associated FileStream FileGroup
I have added an additional entry in sqlcmdvars files:
<Property>
<PropertyName>PathBlobStream</PropertyName>
<PropertyValue>C:\SQLSERVER DATA\$(DatabaseName)\BlobStream\</PropertyValue>
</Property>
But am not sure how to tell the database to use this over what the SchemaObjects\Database Level Objects\Storage\BlobStore.sqlfile.sql has declared:
ALTER DATABASE [$(DatabaseName)]
ADD FILE (NAME = [BlobStore], FILENAME = 'C:\SQLSERVER DATA\####\BlobStream') TO FILEGROUP [BlobStreamFileGroup];
How do you use the new entry in the sqlcmdvars to override the path for the new FileStream file?
The best way I found to do this was add additional entries in the dbproj file to use a different schema file depending on the configuration profile:
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<Build Include="Schema Objects\Database Level Objects\Storage\Files\BlobStore.sqlfile.sql">
<SubType>Code</SubType>
</Build>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Internal' ">
<Build Include="Schema Objects\Database Level Objects\Storage\Files\BlobStore.sqlfile.Internal.sql">
<SubType>Code</SubType>
</Build>
</ItemGroup>
The key was copy/pasting the original schema file and appending the configuration profile name in the file name. This keeps the debug variation with the original file name so that any future schema comparisons will be oblivious to the additional variations. You want to include the additional schema files in source control, but if following suite to the entries above, they won't show up in the project. I verified MSBuild handles this correctly. I'm crossing my fingers that TFS will do the same.