aby paul
aby paul

Reputation: 21

Unable to take differential backup using SQL Server VSS Writer

I have been trying to develop a tool to do backup/restore of MS SQL Server using SQL Server VSS Writer. I can not get the differntial backup working! I am just curious as to whether anyone ever made differential backup using VSS. Here is what I have been doing:

  1. Create a full backup and store files and the Backup component document associated with it.
  2. Update the tables in the database.
  3. Create a new backup by setting 'SetBackupState' as VSS_BT_DIFFERENTIAL
  4. Now when adding the exisiting components to the Backup Component Document, I find the component's time stamp from the document in step 1, and then invoke it with 'SetPreviousBackupStamp'
  5. Now after the snapshot is taken, I go through each of the component and invoke 'GetPartialFileCount' API. This always return the value 0. I am assuming if there is a change in an existing component, it should give a value greater than 0.

Am I missing something here? Do we need to start SQL Server VSS Writer using certain parameters or something? I tried different configurations including (Windows Server 2008/ SQL Server 2008)

Upvotes: 0

Views: 964

Answers (1)

aby paul
aby paul

Reputation: 21

I have been wanting to update this post for a while, but got tied up with all the bugs that I was finding in the program. Couple of folks from Microsoft helped me to nail down to the issue I had. I just want to thank Dileep and Ramesh (I am leaving out their last names for obvious reasons) for helping me get through this.

Here are my findings:

  • SQL VSS Writer does support differential backup.

  • When taking a differential backup, do not include "master" component as a component for backup.

  • Always check for Writer status error after each phase using the following sequence of APIs: GatherWriterStatus(), GetWriterStatusCount(), GetWriterStatus()

  • If the writer status points to an error, from there on things are unpredictable.

  • The best place to start looking for finding the working is BETest source code available as part of VSS SDK.

  • BETest allows backing up single database (Full/Differential) and restore (Full/Differential), so long as you get the /C option correctly. Components syntax is: "{Writer Id}":"Full Component Name" For example, for the database 'Person' on my machine my component info file contained: "{A65FAA63-5EA8-4EBC-9DBD-A0C4DB26912A}":"ABP-PC\SQLEXPRESS\Person";

  • When doing a differential restore, the full restore needs to be done with "/AdditionalRestores" option.

Hope this helps. If somebody needs some help, update this post and I will get notified. I will help.

Upvotes: 2

Related Questions