How to create an exposed snapshot?

Sep 23, 2010 at 9:20 AM
Edited Sep 23, 2010 at 9:30 AM

Hi,

 

I am struggling  a little with how to create an exposed snapshot of the C: drive.  I am able to do with it VSHADOW and then use DOSDEV to assign a drive letter to it but AlphaVSS seems a more elegant way of doing it.

The plan is to use AlphaVSS to create a Volume Shadow C and assign it a drive letter and then use ImageX (or, most probably, SmartWIM) to take an image of it

Here is the code I have so far (found on another thread)

          Dim oVSSImpl As IVssImplementation = VssUtils.LoadImplementation()
        Using oVSS As IVssBackupComponents = oVSSImpl.CreateVssBackupComponents()
            oVSS.InitializeForBackup(Nothing)
            'oVSS.SetContext(Alphaleonis.Win32.Vss.VssVolumeSnapshotAttributes.ExposedLocally)
            oVSS.SetBackupState(False, True, VssBackupType.Full, False)

            Using async As IVssAsync = oVSS.GatherWriterMetadata()
                async.Wait()
            End Using

            Dim gSet As Guid = oVSS.StartSnapshotSet()

            Dim gSnapshot As Guid = oVSS.AddToSnapshotSet("C:\", Guid.Empty)

            Using async As IVssAsync = oVSS.PrepareForBackup()
                async.Wait()
            End Using

            Using async As IVssAsync = oVSS.DoSnapshotSet()
                async.Wait()
            End Using

            Dim oProps As VssSnapshotProperties = oVSS.GetSnapshotProperties(gSnapshot)
            Dim drive As String = oVSS.ExposeSnapshot(gSnapshot, Nothing, VssVolumeSnapshotAttributes.ExposedLocally, "Q:")
        End Using

What am I doing wrong?  I get an "The method or operation is not implemented" error on the ExposeSnapshot method.

I am running this on XP SP3

 

 

Jul 13, 2011 at 1:48 PM

Bumping this as I'm revisiting the code.  I still have the issue of not being able to expose a snapshot on an XP SP3 box.  Is this a limitation of XP?

Coordinator
Jul 13, 2011 at 3:16 PM

According to the documentation on MSDN for the SetContext method:

Windows XP:  The only supported context is the default, VSS_CTX_BACKUP. Calling IVssBackupComponents::SetContext will return E_NOTIMPL.

A bit strange that the error does not appear until the call to ExposeSnapshot, but if my memory serves me correctly, Windows XP does not support exposing snapshots this way.

Furthermore you should not specify ExposedLocally in a call to SetContext, according to MSDN:

VSS_VOLSNAP_ATTR_EXPOSED_LOCALLY

The shadow copy is locally exposed. If this bit flag and the VSS_VOLSNAP_ATTR_EXPOSED_REMOTELY bit flag are not set, the shadow copy is hidden.

The attribute is automatically added to a shadow copy context upon calling the IVssBackupComponents::ExposeSnapshot method to expose a shadow copy locally.

This attribute should not be used explicitly by requesters when setting the context of a shadow copy.


Hopefully this clarifies things somewhat.

Sincerely, Peter.

Jul 14, 2011 at 7:54 AM
Edited Jul 14, 2011 at 9:15 AM

Yeah that's a bit annoying as I was trying to develop something that let me take an image of a remote machine.

Hmm, guess I have to look into DOSDEV

Coordinator
Jul 14, 2011 at 12:01 PM
Edited Jul 14, 2011 at 12:01 PM

You don't actually *have* to expose the drive if you are just going to access it yourself.

Exposing drive letters works on Windows Vista and later, but it may not be desirable from eg. a backup application, to suddenly have a number of new drive letters turn up in explorer. The paths through which the shadow copies are available are extended-length paths, eg. "\\?\Volume{12345678-aac3-31de-3321-3124565341ed}\Program Files" instead of simply "C:\Program Files". However, these paths cannot be accessed using the file system functions exposed by System.IO. Therefore I also created (nowadays with the help of others) the AlphaFS library, which supports access to "long paths" or "extended paths" if you will. So I would recommend going with this solution instead of the somewhat cumbersome approach with exposing drives, especially on Windows XP where you have to use the DOSDEV hack.

Take a look at http://alphafs.codeplex.com if you haven't already.

Jul 14, 2011 at 12:12 PM

Interesting, that might be something I look into later.  For now I have two little project using AlphaVSS

1) Backing up data on Cluster Volumes.  This I've got working with exposed snapshots and I'm happy with

2) Taking images of a remote machine by remotely executing my tool (which also uses the SmartWIM libraries).  Unfortunately, we're still on XP so exposing snapshots isn't possible.  This tool might have to wait until we migrate to Win7 unless I use DOSDEV