共用方式為


Something for the SQL Server Backup Vendors

SQL Server VSS allows ISVs to develop backup solutions using APIs exposed by VSS framework. One such API method which is commonly used while performing differential backup using SQL VSS is IVssComponent::GetPartialFile. While performing differential backup, IVssComponent::GetPartialFile is used iteratively to obtain the range of changed differential bytes for backup which changed since last full backup. The output for GetPartialFile provides the file path, file name and pbstrRange which is a pointer to 64KB string buffercontaining the comma-separated list of the form offset1:length1, offset2:length2, where each offset and length is a 64-bit integer specifying a file offset in bytes and length of the range in bytes, respectively. If the changed differential bytes within a partial file is large enough to fall outside the tracking range limit of the 64 bit string buffer, pbstrRange returns the partial filename containing those ranges instead of the range and offset within the current partial file.

The ISV Backup code should be able to handle both the output for pbstrRange viz offset/length range string for backup range within the current file or filename containing the backup range if the range falls outside the current file.

Following T-SQL sample code can help the backup vendors to simulate this behavior consistently to test and handle this scenario where pbstrRange generates filename. The T-SQL sample code below updates alternate extents to create enough non-contiguous extent such that the changed differential extent range falls outside 64KB buffer so pbstrRange outputs filename containing the ranges to be backed up.

The script is uploaded and made in SQL Server Sample repository in GitHub for the community.

[snippet slug=create-sqlvss_generate_backup_filename_ranges_sample-sql lang=sql]

DISCLAIMER: © 2016 Microsoft Corporation. All rights reserved. Sample scripts in this guide are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

Ravi Mandliya

Software Engineer(@ravi_MSFT)

Parikshit Savjani

Senior Program Manager(@talktosavjani)