Deployment - How to take incremental backup of sqlserver database using MSBuild

Asked By vasu on 28-Jun-12 05:49 AM
Earn up to 30 extra points for answering this tough question.
How to take incremental backup of sqlserver database using MSBuild
[)ia6l0 iii replied to vasu on 28-Jun-12 12:20 PM
You need to use TaskAction as "Backup" and set Incremental to true. See below.

<MSBuild.ExtensionPack.Sql2008.Database 
TaskAction="Backup" 
Incremental="true"
MachineName="machine name"  
DatabaseItem="database name" 
DataFilePath="\\backups\Test.bak"
>

Hope this helps.

Jitendra Faye replied to vasu on 29-Jun-12 12:40 AM
For this you can try like this-

 <MSBuild.ExtensionPack.Sql2008.Database TaskAction="Backup" DatabaseItem="$(DatabaseName)" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath="$(ProductionBackup)"/>


Refer this link-

http://stackoverflow.com/questions/9018334/msbuild-extensionpack-verify-backup-remote
bharti odedra replied to vasu on 29-Jun-12 07:09 AM
try this
<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"\\$(SQLInstance)\C$\DatabaseBackups\MyDB.bak"
/>
        <!-- Verify a database backup -->
        <MSBuild.ExtensionPack.Sql2008.Database TaskAction="VerifyBackup" MachineName="$(SqlInstance)" UserName="$(SqlUserName)" UserPassword="$(SqlPassword)" DataFilePath"\\$(SQLInstance)\DatabaseBackups\MyDB.bak"

/>
    </Target>
</Project>

bharti odedra replied to vasu on 29-Jun-12 07:14 AM
try this

<MSBuild.ExtensionPack.Sql2008.Database 
         TaskAction="Backup" 
         Incremental="true"
         MachineName="machine name"  
         DatabaseItem="database name" 
         DataFilePath="\\backups\t.bak"
>