I am trying to restore a sql server database from a .bak file (database backup file) using the wix 3.9 installer. But, unfortunately, this does not happen. Here are my trial codes
<Fragment> <Binary Id="PHRBackupBin" SourceFile="Database/PHR.bak"></Binary> <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 starts up successfully if I replace the .sql file (sql script) . I also tried writing a script file to restore the database, but no luck. May I ask the community how to run the .bak file from the wix installer.
Thanks in advance
Vivek source share