Windows Server 2008 : Manipulating Shadow Copies with vssadmin

vssadmin is the volume shadow copy service administrative command-line tool. You can use it to view and manipulate shadow copies.

Volume shadow copies are used to create previous versions of files (as shown in Figure 1) and when doing backups by allowing open files to be copied.

Figure 1. Restoring a previous version of a file

 

The following table shows some common uses of the vssadmin tool.

vssadmin Command Comments
query reverts
vssadmin query reverts
/for= x: | /all
c:\>vssadmin query reverts
/all
c:\>vssadmin query reverts
/for=e:


Queries the progress of the in-progress previous version restore operations. You can query the status of a restore operation for a specific drive or for all drives.

Tip

This is useful if a large file is being restored using previous versions and you want to check the status.


revert shadow
vssadmin revert shadow
/shadow= {guid}
[/forcedismount]
c:\>vssadmin revert shadow
/shadow={54e0d057-fcf7-4aa2-
95ef-72390436d420}
c:\>vssadmin revert shadow
/shadow={54e0d057-fcf7-4aa2-
95ef-72390436d420}
/forcedismount


Reverts a volume to a shadow copy. The shadow copy is identified by the GUID (which is obtained from the vssadmin list shadows command). Spaces are not allowed before or after the equal sign (=) in the /shadow switch.

Tip

This is the same as accessing the Shadow Copies properties from Computer Management, selecting a shadow copy, and clicking the Revert button (as shown in Figure 2).


Warning

Any changes made to files since the shadow copy was created will be lost.


list shadows
c:\>vssadmin list shadows


Lists existing volume shadow copies. This output includes the time each shadow copy is created and the globally unique identifier (GUID).
list volumes
c:\>vssadmin list volumes


Lists volumes that can be, or are, configured for shadow copies. Volumes are identified by the drive name and by the drive GUID.
create shadow
vssadmin create shadow
/for= x: [/autoretry= mins]
c:\>vssadmin create shadow
/for=e: /autoretry = 10


Creates a new volume shadow copy. This is useful if you want to create an unscheduled shadow copy. If another process is creating a shadow copy, the /autoretry switch can be used to specify how many minutes to continue to retry the operation.
delete shadows
vssadmin delete shadows /all
vssadmin delete shadows
/for= x:
vssadmin delete shadows
/shadow= {guid}
vssadmin delete shadows /all
c:\>vssadmin create shadow
/for= e:


Deletes volume shadow copies. You can delete all the shadow copies on the system, all the shadow copies for a specific drive, or a specific shadow copy identified by the GUID. New shadow copies will continue to be created based on the schedule. You can use this to reclaim space taken by shadow copies.
list shadowstorage
c:\>vssadmin list
shadowstorage


Lists volume shadow copy storage associations, including how much is used, how much is allocated, and the maximum that can be allocated.
resize shadowstorage
vssadmin resize
shadowstorage /for= x:
/on= x: /maxsize=size
c:\>vssadmin resize
shadowstorage /for=d:
/on=e: /maxsize= 1 GB


Resizes a volume shadow copy storage association. The /for switch identifies which drive shadow copies are created for, and the /on switch identifies the location to store the shadow copies. You can specify the size as KB, MB, GB, TB, PB, and EB.
add shadowstorage
vssadmin add shadowstorage
/for= x: /on= x: /maxsize= size
c:\>vssadmin add
shadowstorage /for=d:
/on=e: /maxsize= 1 GB


Adds a new volume shadow copy storage association. The same switches used for resize shadowstorage are used on add shadowstorage.
delete shadowstorage
vssadmin delete shadowstorage
/for= x: [/quiet]
c:\>vssadmin delete
shadowstorage /for=d: /quiet


Deletes volume shadow copy storage associations. This effectively stops shadow copy creation on the specified volume. All shadow copies are deleted, returning the space to the system. The /quiet switch suppresses confirmation prompts, which is useful in a script.

Figure 2. Reverting all previous versions for a specific volume


Tip

You can access the Shadow Copies tool shown in Figure 2 on a Windows Server 2008 system by entering vssuirun at an administrator prompt.