VSS

最後更新: 2018-10-10

目錄

  •  

介紹

 

Diagram

[requester] -> [service] <--> [writers]
                   |              |
             [Software/Hardware provider]

VSS Element

VSS requester  

The software that requests the actual creation of shadow copies

(or other high-level operations like importing or deleting them)

Typically, this is the backup application

VSS provider  

The component that creates and maintains the shadow copies.

This can occur in the software or in the hardware.

The Windows operating system includes a VSS provider that uses copy-on-write.

If you use a storage area network (SAN), it is important that you install the VSS hardware provider for the SAN,

if one is provided. A hardware provider offloads the task of creating and maintaining a shadow copy from the host operating system.

VSS writers

The VSS implementation is slightly more advanced than a simple snapshot.

It also supports a notification system, through which any program can register itself as a writer.

When a snapshot is requested, VSS will notify each registered writer.

This allows any program to flush data to disk before creating a snapshot

i.e.

  • Requestor (Cobian Backup 11 Volume Shadow Copy Requester)
  • Writer (SQL Server VSS Writer)

* vssadmin 要 Administor 權限才行到

Volume Shadow Copy Service Tools

 


Windows 7 Default VSS setting

 

By default, shadow copy will save a copy of your files once a day,

or when activated explicitly such as when installing an update or new program.

The default is 3% of your hard drive included in every edition of Windows 7

 


Get a list of registered writers:

vssadmin list writers

書寫器名稱: 'COM+ REGDB Writer'
   書寫器識別碼: {542da469-d3e1-473c-9f4f-7847f01fc64f}
   書寫器例項識別碼: {fc59dede-6b7b-4e9d-9449-d8a66f53755b}
   狀態: [1] 穩定
   上個錯誤: 沒有錯誤

書寫器名稱: 'BITS Writer'
   書寫器識別碼: {4969d978-be47-48b0-b100-f328f07ac1e0}
   書寫器例項識別碼: {0bb4102c-12fa-4cc0-a7f0-5c5b58c0450d}
   狀態: [1] 穩定
   上個錯誤: 沒有錯誤

 


Lists registered "providers"

vssadmin list providers

Provider name: 'Microsoft Software Shadow Copy provider 1.0'
   Provider type: System
   Provider Id: {b5946137-7b9f-4925-af80-51abd60b20d5}
   Version: 1.0.0.7

* Default 得呢個

system provider:

To maintain the "point-in-time" view of a volume that is contained in a shadow copy, the system provider uses a copy-on-write technique. Copies of the blocks on volume that have been modified since the beginning of the shadow copy creation are stored in a shadow copy storage area.

The system provider can expose the production volume, which can be written to and read from normally. When the shadow copy is needed, it logically applies the differences to data on the production volume to expose the complete shadow copy.

The component files that make up the system provider are swprv.dll and volsnap.sys.

 


Manually Usage

 

查那個 drive 有啟用 shadowcopy

vssadmin list shadowstorage

Shadow Copy Storage association
   For volume: (C:)\\?\Volume{a2ceea68-a966-11dc-ad9c-806e6f6e6963}\
   Shadow Copy Storage volume: (C:)\\?\Volume{a2ceea68-a966-11dc-ad9c-806e6f6e6963}\
   Used Shadow Copy Storage space: 0 B
   Allocated Shadow Copy Storage space: 0 B
   Maximum Shadow Copy Storage space: 19.531 GB

指定一個 Drive

vssadmin List ShadowStorage /For=g:

查看有什麼 shadowcopy 建立了

vssadmin list shadows

Contents of shadow copy set ID: {4c7b5712-1a56-402b-b32e-d026d581a873}
   Contained 1 shadow copies at creation time: 8/31/2015 3:55:51 PM
      Shadow Copy ID: {5cd7aace-bd36-44c6-bfb2-174b7cca93f5}
         Original Volume: (C:)\\?\Volume{a2ceea68-a966-11dc-ad9c-806e6f6e6963}\
         Shadow Copy Volume: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy187
         Originating Machine: MyServer
         Service Machine: MyServer
         Provider: 'Microsoft Software Shadow Copy provider 1.0'
         Type: ClientAccessible
         Attributes: Persistent, Client-accessible, No auto release, No writers, Differential

指定一個 Drive

vssadmin list shadows /For=g:

Create shadowcopy

vssadmin create shadow /for=c:

* win7 的 vssadmin 係無 "create" 這 opts 的.

更改 Maximum Shadow Copy Storage space

vssadmin resize shadowstorage /for=g: /On=g: /maxsize=20%

The "/for" Specifies the volume for which the maximum amount of storage space is to be resized.

The "/on" flag specifies where the shadow storage will be put

Add shadowstorage

vssadmin add shadowstorage /for=<drive being backed up> /on=<drive to store the shadow copy> /maxsize=<percentage of disk space to allow to be used>

Deletes shadowcopy

vssadmin delete shadows /for=<ForVolumeSpec> [/oldest | /all | /shadow=<ShadowID>]

 


建立過程

 

*4 Each writer prepares the data as appropriate, such as completing all open transactions,

rolling transaction logs, and flushing caches. When the data is ready to be shadow-copied,

the writer notifies the Volume Shadow Copy Service.

*6 The Volume Shadow Copy Service tells the provider to create the shadow copy.

The shadow copy creation period lasts no more than 10 seconds,

during which all write I/O requests to the file system remain frozen.

*7 The Volume Shadow Copy Service releases file system write I/O requests.
   VSS tells the writers to thaw application write I/O requests.

 


Daily 建立 Shadow Copy

 

taskschd.msc

Name: Shadow Copy Backup

Action > Select "Start a program"

At 'Program/script', type:

wmic

At 'Add arguments (optional)' filed type:

shadowcopy call create Volume=C:\

 * Run whether user is logged on or not

 * Run with highest privileges

 


Provider Methods

 

A hardware or software shadow copy provider methods

   * Complete copy
   * Copy-on-write  
   * Redirect-on-write

Tn: 發生時間

T0    Original data: 1 2 3 4 5

T1    Data changed in cache: 3 to 3’

Shadow copy (status and data):

cow: Shadow copy created (differences only): 3

Original data overwritten: 1 2 3’ 4 5

The copied blocks in the diff area can be combined with the changed data on the original volume to restore the volume to its state before any of the changes were made.

If there are many changes, the copy-on-write method can become expensive.

row: Shadow copy created (differences only): 3’

Original data unchanged: 1 2 3 4 5

The copied blocks in the diff area can be combined with the unchanged data on the original volume to create a complete, up-to-date copy of the data.

If there are many read I/O requests, the redirect-on-write method can become expensive.

 


Troubleshoot

 

If you do not receive VSS writer errors when using vssadmin list writers, but the system isn’t able to create a new VSS snapshot (and you have deleted all existing snapshots), continue with the following steps:

    Uninstall all backup software on your computer, including Windows Backup if it is installed. We have seen VSS writers of other backup software manufacturers cause system instability and errors.
    In an elevated Command Prompt type regedit, Enter. Go to HKLM\SYSTEM\CurrentControlSet\services\VSS\Providers, expand the folder, and check listed providers
    You should only find Microsoft Software Shadow Copy Provider. If you do find others, they may be residual registry entries from previous backup software installations. You can save the entry by exporting the residual providers folder (right click and select Export) and then it’s safe to delete the entire branch entry underneath.
    Reboot, open an elevated Command Prompt, type vssadmin list writers, Enter to confirm the problem has been resolved.

Error1:

    2015-08-28_05-01 Deleting the Volume Shadow Copy snapshot "1cf0db28-0cf2-4490-aac2-e86e2569321d"
ERR 2015-08-28_05-06 Timed out while waiting for an answer from the Volume Shadow Copy requester

Solution1:

<0> Verify if these two services are running:

net start | find "Volume Shadow Copy"

Volume Shadow Copy

<1> Try increasing the VSC timeout then.

* The default is 3 min, but if your disk is very fragmented you may need more.

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\SPP

CreateTimeout

DWORD (32-bit)

600000 (10 minutes in milliseconds).

 


Troubleshoot

 

 

[1]

Error: VSS Error 0x80042316

Description

VSS snapshot can't create new one copy if another backup VSS process is running.

[Fix] Restart the ALL(vss, Requestor) vss service

i.e.

  • VSS              # Volume Shadow Copy
  • cbVSCService11   # Cobian Backup 11 Volume Shadow Copy Requester
  • SQLWriter        # SQL Server VSS Writer

# "&" is the Bash equivalent for ";"

net stop vss & net start vss

 


Enable VSS

 

S2019

Win + X > Disk Management > Right-click Partition (e.g. C:) > Shadow Copies

Win10

Control Panel\System and Security\System
Advanced system settings > System Protection

 


Doc

https://technet.microsoft.com/en-us/library/ee923636%28v=ws.10%29.aspx

 

附加檔案大小
dia.jpg31.57 KB