Git Product home page Git Product logo

alphavss's Introduction

AlphaVSS

Inactively Maintained License Build Latest Prerelease Downloads

AlphaVSS is a .NET class library providing a managed API for the Volume Shadow Copy Service also known as VSS. The Volume Shadow Copy Service is a set of COM interfaces that implements a framework to allow volume backups to be performed while applications on a system continue to write to the volumes.

AlphaVSS, written in C# and C++/CLI provides a managed interface to this API.

The goal of AlphaVSS is to provide an interface that is simple to use from any .NET application, yet provides the full functionality of VSS.

For documentation and more information see http://alphavss.alphaleonis.com

For samples, see https://github.com/alphaleonis/AlphaVSS-Samples

alphavss's People

Contributors

alphaleonis avatar chris3773 avatar mark-raymond avatar stil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alphavss's Issues

python implementation of AlphaVSS

Howdy, There's no issue, but I wanted to leave a reference here so that if someone found your repo, they might also know there is a Python implementation that I've started work on (using your library as the base), and wanted to thank your project team members for their work and documentation.

I've gotten the basic functionality working, and hope this helps someone else. It's possible I'll include support for AlphaFS as well, but for now, the only thing I think I need so far is the "Volume.GetVolumeDisplayName" code and I have WMI doing that part for me now.

https://github.com/smanross/python-alphavss

Thank You Very Much,
Steven

FileNotFoundException copying files (or creating a stream)

Hi, I'm having this problem:

2020-02-04_17-09-13

Trying to copy files from my local drive, AlphaFS gives a "FileNotFoundException" on shadowed files and/or calling a GetStream()

I used the exact code from the samples

Win10 18363.592, executed as administrator.

Internal field not properly initialized and released in VssBackupComponents.

Hello. I think there is a bug in the code.
Shouldn't m_IVssBackupComponentsEx4(0) also be there?

VssBackupComponents::VssBackupComponents()
            : m_backup(0),
            m_IVssBackupComponentsEx(0),
            m_IVssBackupComponentsEx2(0),
            m_IVssBackupComponentsEx3(0),
            m_writerMetadata(nullptr),
            m_writerComponents(nullptr),
            m_writerStatus(nullptr)

         {
            m_writerMetadata = gcnew WriterMetadataList(this);
            m_writerComponents = gcnew WriterComponentsList(this);
            m_writerStatus = gcnew WriterStatusList(this);

            pin_ptr<::IVssBackupComponents*> pVssObject = &m_backup;
            CheckCom(CreateVssBackupComponents(pVssObject));
         }

         VssBackupComponents::~VssBackupComponents()
         {
            this->!VssBackupComponents();
         }

         VssBackupComponents::!VssBackupComponents()
         {
            if (m_backup != 0)
            {
               m_backup->Release();
               m_backup = 0;
            }

            if (m_IVssBackupComponentsEx != 0)
            {
               m_IVssBackupComponentsEx->Release();
               m_IVssBackupComponentsEx = 0;
            }

            if (m_IVssBackupComponentsEx2 != 0)
            {
               m_IVssBackupComponentsEx2->Release();
               m_IVssBackupComponentsEx2 = 0;
            }

            if (m_IVssBackupComponentsEx3 != 0)
            {
               m_IVssBackupComponentsEx3->Release();
               m_IVssBackupComponentsEx3 = 0;
            }
         }

Can't use AlphaVSS in x86 app

I work on a .NET 4.6.1 app, built for platform x86, and I can't use AlphaVSS because it tries to load the AlphaVSS.x64 assembly.

I tried on an empty Console project :

using Alphaleonis.Win32.Vss;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            VssUtils.LoadImplementation();
        }
    }
}

If the app targets platform x86 or Any CPU with 'Prefer 32-bit' checked, I get this error at runtime :
System.BadImageFormatException: 'Impossible de charger le fichier ou l'assembly 'AlphaVSS.x64, Version=1.4.0.0, Culture=neutral, PublicKeyToken=959d3993561034e3' ou une de ses dépendances. Tentative de chargement d’un programme de format incorrect.'

When built for Any CPU or x64, it's ok.

I saw that there are both AlphaVSS.x64.dll and AlphaVSS.x86.dll in the NuGet package, do we have something to do to use the x86 assembly ?

Add versions built for .NET 4.0

.NET 4.0 may still be required for use by some people out there. And it can easily be built with VS2015 as well it seems.

UnauthorizedAccessException for Cygwin files with restrictive access rights

Hi,
I'm not sure if this is a bug or works as intended.
I use Duplicati 2.0.1.72_canary_2017-07-05 and snapshot-policy=Required - Duplicati is running as a service on Win7x64. The user running the service is SYSTEM (S-1-5-18).

Error reported while accessing file: C:\cygwin\home\user\.ssh\

System.UnauthorizedAccessException: (5) Zugriff verweigert: [\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy13\cygwin\home\user\.ssh\*]
   bei Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
   bei Alphaleonis.Win32.Filesystem.FindFileSystemEntryInfo.FindFirstFile(String pathLp, WIN32_FIND_DATA& win32FindData)
   bei Alphaleonis.Win32.Filesystem.FindFileSystemEntryInfo.<Enumerate>d__3`1.MoveNext()
   bei System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   bei System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   bei Duplicati.Library.Snapshots.WindowsSnapshot.ListFolders(String folder)
   bei Duplicati.Library.Utility.Utility.<EnumerateFileSystemEntries>d__22.MoveNext()

I think this should not happen. I can imagine a workaround but is there a universal solution?
The folder looks like this via ls: drwx------+ 1 user Domain Users 0 1. Okt 2016 .ssh/

System.UnauthorizedAccessException:“(5) 拒绝访问

When I ran the sample code, an UnauthorizedAccessException exception occurred。Here are some error messages as follows:

System.UnauthorizedAccessException
HResult=0x80070005
Message=(5) 拒绝访问。: [\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy8\Windows\system32\config\sam]
Source=AlphaFS
StackTrace:
at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
at Alphaleonis.Win32.Filesystem.File.RestartCopyMoveOrThrowException(Int32 lastError, Boolean isFolder, Boolean isMove, KernelTransaction transaction, String sourcePathLp, String destinationPathLp, Nullable1 moveOptions) at Alphaleonis.Win32.Filesystem.File.CopyMoveCore(KernelTransaction transaction, Boolean driveChecked, Boolean isFolder, String sourcePath, String destinationPath, Nullable1 copyOptions, Nullable`1 moveOptions, Boolean preserveDates, CopyMoveProgressRoutine progressHandler, Object userProgressData, CopyMoveResult copyMoveResult, PathFormat pathFormat)
at Alphaleonis.Win32.Filesystem.File.Copy(String sourcePath, String destinationPath)
at VssSample.Examples.Example1() in D:\workSpace\visualStudio\AlphaVSS-Samples\src\VssBackup\Examples.cs:line 43
at VssSample.Examples.Main(String[] args) in D:\workSpace\visualStudio\AlphaVSS-Samples\src\VssBackup\Examples.cs:line 16

AlphaVSS and Dispose()?

My goal is to read SQL Server's files (mdf/ldf) with AlphaVSS and to remove snapshot after that (if I understand it correctly). So my code (based on example) in object's constructor

    private readonly VssBackup Vss;
    private readonly Stream VssStream;
...
          Vss = new VssBackup();
          Vss.Setup(Path.GetPathRoot(fileName));
          VssStream = Vss.GetStream(fileName);
          Length = VssStream.Length;

and in destructor

          VssStream.Close();
          Vss.Dispose();

Without Dispose it works without exceptions, but Delete for snapshot never called. With Dispose() I have "System.NullReferenceException: 'Object reference not set to an instance of an object.'" in Snapshot.cs

      public void Delete()
      {
         _backup.DeleteSnapshotSet(_set_id, false);
      }

Am I need to use Dispose and is everything OK with code?

How can I backup the mdf and ldf files with vss?

Hi,
When I create the snapshot by AlphaVSS, it seems not using SqlServer writer to freeze IO.
The mdf and ldf files timestamp is the old. It is not flush.

May I do something to freeze IO and flush data when create the snapshot ?

Could Not Load file or assembly 'AlphaVSS.x64.dll'

Hi i write application using c# and it working fine in my laptop. after that i deploy to production machine but it failed to load assembly AlphaVss.x64.dll which i already include in bin folder

could you rectify why this happen

Thank you

Cloning Drive

I haven't touched C#, C++, or VB in about a decade, and am trying to set up a process for cloning a drive while it is in use. I've been piecing things together from what I found online, but everything I find is intended for copying sets of files, instead of cloning an entire drive.

I would need to deploy to over 3,000 machines that are typically running 24/7, and clone the active drive to a secondary one that is connected to the machine. The secondary drive would be statically assigned a specific Drive Letter by the time this process runs, and the drives are always in the same SATA ports from one machine to another. Currently, a script making use of Robocopy keeps all vital data mirrored from one drive to another, however after any significant software update (occurs roughly once every 3 months, and can take anywhere from 1-6 months before it's rolled out to all machines) we have to remotely connect and clone the drive using a third party program and a graphic interface.

IList<VssWMFileDescriptor^>^ VssExamineWriterMetadata::ExcludeFiles::get() is empty

Consider the following:

                    IList<IVssExamineWriterMetadata> writers = _backup.WriterMetadata;
                    foreach (IVssExamineWriterMetadata metadata in writers)
                    {
                        //metadata.ExcludeFiles is always empty

                    }

The bug is in:
IList<VssWMFileDescriptor^>^ VssExamineWriterMetadata::ExcludeFiles::get()

And the fix is:

   IList<VssWMFileDescriptor^>^ VssExamineWriterMetadata::ExcludeFiles::get()
   {
      if (m_excludeFiles != nullptr)
         return m_excludeFiles;

      UINT cIncludeFiles, cExcludeFiles, cComponents;
      CheckCom(mExamineWriterMetadata->GetFileCounts(&cIncludeFiles, &cExcludeFiles, &cComponents));

      List<VssWMFileDescriptor^>^ list = gcnew List<VssWMFileDescriptor^>(cExcludeFiles); //List instead of IList
      for (UINT i = 0; i < cExcludeFiles; i++)
      {
         IVssWMFiledesc *filedesc;
         CheckCom(mExamineWriterMetadata->GetExcludeFile(i, &filedesc));
         list->Add(CreateVssWMFileDescriptor(filedesc));
      }
      m_excludeFiles = list->AsReadOnly(); // Return ReadOnly copy
      return m_excludeFiles;
   }

Using from a Windows Service

Does the AlphaVSS code work when running from within a Windows Service?

In my tests, it seems to crash on this line when I try to run it from within a .NET Service project.

IVssImplementation _vssImplementation = VssUtils.LoadImplementation();

It works perfectly if I run out from a normal Windows process.

Thanks in advance for any tips.

John.

Add support for .NET Core

I'm building a service with web interface, hence .net Core. Cannot get it to work with AlphaVSS. Specifically it claims it can't find AlphaVSS.x64. Also my project moans about the nuget package targeting .net framework with may not be compatible with .net core 2

How to create VSS Differential backup copies using alphavss?

Hello,

I wanted to create differential copies of my data using alpha vss. Is there any way to achieve that? I tried changing backupstate to Differential and PartialFile support as True, but that leads to failure in taking snapshot. Pleas help.

NEW LOGO

Hello alphaleonis.!
You have a great app, unfortunately this app does not have a logo yet, may I donate a logo for your app?

how to provide vss backup as it be displayed in previouse version tab?

hi guys .

i intend to get vss (volume shadow copy services) backup from a drive by "alphavss" wrapper in c# as my backup be displayed in previous version tab of it's drive (properties > previous version) .

i write below code :

` IVssImplementation vssImplementation = VssUtils.LoadImplementation();
using (IVssBackupComponents vssBackup = vssImplementation.CreateVssBackupComponents())
{
vssBackup.InitializeForBackup(null);

            vssBackup.GatherWriterMetadata();
            vssBackup.SetContext(VssSnapshotContext.Backup);
            vssBackup.SetBackupState(false, false, VssBackupType.Full, false);  
            Guid MyGuid_1 = vssBackup.StartSnapshotSet();
            Guid MyGuid_2 = vssBackup.AddToSnapshotSet("F:\\"); 
            vssBackup.PrepareForBackup(); 
            vssBackup.DoSnapshotSet(); 

        }`

this code provide vss backup .

but gotten backup don't appear in previous version tab .

i changed attributes in "SetContext" method :

`vssBackup.SetContext(VssVolumeSnapshotAttributes.Persistent | VssVolumeSnapshotAttributes.ClientAccessible | VssVolumeSnapshotAttributes.NoAutoRelease | VssVolumeSnapshotAttributes.Differential | VssVolumeSnapshotAttributes.AutoRecover);

vssBackup.SetBackupState(false, false, VssBackupType.Full, false);`

but i get this error :

"Alphaleonis.Win32.Vss.VssUnsupportedContextException: 'The operation is not supported under the current context."

how to i change this code to my backup be displayed in previous version tab of it's drive?

thanks

Error loading dll

Hi,

I tried to implement some code around your Classes and faced an issue at runtime (System.IO.FileNotFoundException). Then I tried the standalone AlphaShadow.exe and this is the output:

`AlphaShadow v1.3 - AlphaVSS Volume Shadow Copy Library Sample Client
Copyright © Peter Palotas 2008-2012

Error: Could not load file or assembly 'AlphaVSS.x64.dll' or one of
its dependencies. The specified module could not be found.`

Any ideas? Target-Platform is Windows Server 2012 R1 with .NET Framework 4.5.2 installed.`

Thanks and cheers, Martin

VssBadStateException when StartSnapshotSet is initializing

Hi there, I have little problem with StartSnapshotSet method. When I initialize it, it's giving me VssBadStateException error. I don't know, what to do. VSS Writers are all stable without errors.

`static Guid _set_id;
static void Main(string[] args)
{
IVssImplementation vssImplementation = VssUtils.LoadImplementation();
using (IVssBackupComponents backup = vssImplementation.CreateVssBackupComponents())
{
backup.InitializeForBackup(null);

            backup.SetBackupState(false, true, VssBackupType.Full, false);
            backup.GatherWriterMetadata();
            backup.GatherWriterStatus();

            _set_id = backup.StartSnapshotSet();`

Administrator rights

Hi,
I am using the 1.2.4000.3 version of the library because I still need to use fw 4.0.
I only tryed to call the IVssImplementation.GetSnapshotCompatibility method, but it seems to require to be run as administrator to work.
Is it mandatory to run as administrator or is there a way to run without administrative rights?
I am administrator on my machine and I also tried to add my user in the Backup Operators group, but I still need to run as administrator the test program.
Thanks
Francesco

Implement async support using TPL.

I looked for a way to email you some stuff, but ...

You don't [yet] support .net 4.5 async functions. I have added it with very little effort, thought maybe it would help.

Added to your IVssAsyncResult interface:

/// <summary>Current status of the work</summary>
uint QueryStatus();
/// <summary>Wait a period of time.  Result is true only if completed successfully.</summary>
bool Wait(TimeSpan TimeOut);

Then added an extension:

/// Provides extensions (note - only works in NET35 and higher
public static partial class Extensions
{
public static TimeSpan
TimeOut_Default = new TimeSpan(0, 5, 0);
/// Provides an awaitable process while running async operations
/// Since this is an extension, this is the object being extended
/// Maximum time to wait (default uses the static field "TimeOut_Default")
/// If operation succeded before the timeout occured, true. Otherwise false.
async static public System.Threading.Tasks.Task WaitAsync(this IVssAsyncResult Async, TimeSpan TimeOut)
{
if (Async==null || Async.IsCompleted)
return true;
System.Diagnostics.StackTrace // this part isn't necessary ... helps me follow the true stack
preException = new System.Diagnostics.StackTrace(1, true);
if (TimeOut.Milliseconds <= 0)
TimeOut = TimeOut_Default;
try
{
System.Threading.Tasks.Task
tsk = new System.Threading.Tasks.Task(() => { return Async.Wait(TimeOut); });
if (tsk.Status == System.Threading.Tasks.TaskStatus.Created)
tsk.Start();

    await tsk;

    if (tsk.Exception != null)
        throw tsk.Exception;

    return tsk.Result;
}
catch (Exception ex)
{ // this part isn't necessary ... helps me follow the true stack
    Exception
        iEx = new Exception("Fail waiting on Asyncronous operation");
    zDougie.ExceptionExtensions.SetStack(ex, preException.ToString());
    zDougie.ExceptionExtensions.InnerException(ex, iEx);
    zDougie.ExceptionExtensions.Rethrow(ex);
    return false; // will never happen - here just to keep compiler happy
}

}
}

Then I added a few lines to your C++:

namespace Alphaleonis {
namespace Win32 {
namespace Vss
{
VssAsyncResult::VssAsyncResult(::IVssAsync *vssAsync, AsyncCallback^ userCallback, Object^ asyncState)
    : m_isComplete(0), m_asyncCallback(userCallback), m_asyncState(asyncState), m_asyncWaitHandle(nullptr), m_vssAsync(vssAsync), m_exception(nullptr)
{
    if (!ThreadPool::QueueUserWorkItem(gcnew WaitCallback(this, &VssAsyncResult::WaitForAsyncCompletion)))
    {
        throw gcnew Exception(L"ThreadPool::QueueUserWorkItem failed.");
    }
}

void VssAsyncResult::WaitForAsyncCompletion(Object^ state)
{
    HRESULT hrResult;
#if ZDOUGIE
    if (IsCompleted || m_vssAsync == 0)
        return;
#endif
    hrResult = m_vssAsync->Wait();

    int prevState = Interlocked::Exchange(m_isComplete, -1);

    if (prevState != 0)
        throw gcnew InvalidOperationException("WaitForAsyncCompletion can only be called once.");

    if (SUCCEEDED(hrResult))
    {
#if ZDOUGIE
        bool
            t1 = m_vssAsync != 0,
            t2 = m_vssAsync == nullptr,
            t3 = m_vssAsync == NULL;

        if (m_vssAsync != 0)
        {
            HRESULT hr = m_vssAsync->QueryStatus(&hrResult, NULL);
            if (FAILED(hr))
                hrResult = hr;
        }
#else
        HRESULT hr = m_vssAsync->QueryStatus(&hrResult, NULL);
        if (FAILED(hr))
            hrResult = hr;
#endif
    }

    if (FAILED(hrResult))
        m_exception = GetExceptionForHr(hrResult);
    else if (hrResult == VSS_S_ASYNC_CANCELLED)
        m_exception = gcnew OperationCanceledException();

    if (m_asyncWaitHandle != nullptr)
        m_asyncWaitHandle->Set();

    if (m_asyncCallback != nullptr)
        m_asyncCallback(this);
}

void VssAsyncResult::EndInvoke()
{
    // This method assumes that only 1 thread calls EndInvoke 
    // for this object
    if (!IsCompleted)
    {
        AsyncWaitHandle->WaitOne();
        AsyncWaitHandle->Close();
        m_asyncWaitHandle = nullptr;
    }

    if (m_exception != nullptr)
        throw m_exception;

}

Object^ VssAsyncResult::AsyncState::get()
{
    return m_asyncState;
}

bool VssAsyncResult::CompletedSynchronously::get()
{
    return false;
}

WaitHandle^ VssAsyncResult::AsyncWaitHandle::get()
{
    if (m_asyncWaitHandle == nullptr)
    {
        bool done = IsCompleted;
        ManualResetEvent^ ev = gcnew ManualResetEvent(done);
        if (Interlocked::CompareExchange<ManualResetEvent^>(m_asyncWaitHandle, ev, nullptr) != nullptr)
        {
            ev->Close();
        }
        else
        {
            if (!done && IsCompleted)
            {
                m_asyncWaitHandle->Set();
            }
        }
    }
    return m_asyncWaitHandle;
}

bool VssAsyncResult::IsCompleted::get()
{
    return Thread::VolatileRead(m_isComplete) != 0;
}

VssAsyncResult^ VssAsyncResult::Create(::IVssAsync *vssAsync, AsyncCallback^ userCallback, Object^ asyncState)
{
    try
    {
        return gcnew VssAsyncResult(vssAsync, userCallback, asyncState);
    }
    catch (...)
    {
        vssAsync->Release();
        throw;
    }
}

VssAsyncResult::~VssAsyncResult()
{
    this->!VssAsyncResult();
}

VssAsyncResult::!VssAsyncResult()
{
    if (m_vssAsync != 0)
    {
        m_vssAsync->Release();
        m_vssAsync = 0;
    }
}

void VssAsyncResult::Cancel()
{
#if ZDOUGIE 
    if (m_vssAsync != 0)
    {
        CheckCom(m_vssAsync->Cancel());
    }
#endif // ZDOUGIE 
}

#if ZDOUGIE && NET45

UINT VssAsyncResult::QueryStatus()
{
    if (m_vssAsync != 0)
    {
        HRESULT 
            hr = 0;
        Int32
            resv = 0;
        CheckCom(m_vssAsync->QueryStatus(&hr, &resv));
        return hr;
    }
    return (zDougie::NativeMethods::NtStatus)S_OK;
}

bool VssAsyncResult::Wait(TimeSpan TimeOut)
{
    if (m_vssAsync != 0)
    {
        UInt32
            ms = (UInt32)TimeOut.TotalMilliseconds;
        if (ms <= 0)
            ms = 1000 * 5 * 60;
        UINT
            result = m_vssAsync->Wait(ms);
        if ((UINT)result == VSS_E_UNEXPECTED || (UINT)result == E_ACCESSDENIED)
            zDougie::NativeMethods::ThrowOnFailure(result, "Waiting for Async Operation");
        return (UINT)result == S_OK;
    }
    return true;
}
#endif // ZDOUGIE && NET45
}
}}

Thanks,

AccessViolationException v1.4.0.0

Hi,
I faced with strange error while performing backup of sql databases on Win2012r2.
Machine which is failing to backup has 100 sql databases on C: drive.
Other machines with less number of dbs are being successfully backed up.
AlphaVSS version is 1.4.0.0

It might be related to XML document modification via msxml3.dll

OS Name: Microsoft Windows Server 2012 R2 Datacenter
OS Version: 6.3.9600 N/A Build 9600

.NET versions:

ComputerName     Build Version                       Comment
------------     ----- -------                       -------
W2012-S2012      50727 2.0.50727.4927
W2012-S2012      30729 3.0.30729.4926
W2012-S2012      30729 3.5.30729.4926
W2012-S2012     378675 4.5.1                         (8.1/2012R2)

The app terminates unexpectedly and event viewer contains the following errors related to AlphaVSS:



Faulting application name: alphabackup.exe, version: 0.1.7060.29100, time stamp: 0x5cc99aab
Faulting module name: msxml3.dll, version: 8.110.9600.16483, time stamp: 0x52a50e5c
Exception code: 0xc0000005
Fault offset: 0x0000000000001d84
Faulting process id: 0x145c
Faulting application start time: 0x01d500222b15f250
Faulting application path: C:\alphabackup.exe
Faulting module path: C:\Windows\System32\msxml3.dll
Report Id: 6b6eca3b-6c15-11e9-80d3-000c29a02e5f
Faulting package full name: 
Faulting package-relative application ID: 

Application: alphabackup.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at Alphaleonis.Win32.Vss.VssWriterComponents+ComponentList.get_Count()
   at Alphaleonis.Win32.Vss.VssListAdapter`1+Enumerator[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
   at AlphaBackup.Vss.AlphaVssExtensions.GetVssComponent(Alphaleonis.Win32.Vss.IVssBackupComponents, AlphaBackup.Vss.Descriptors.VssComponentDescriptor)
   ......
   at AlphaBackup.Program.Main(System.String[])


Faulting application name: alphabackup.exe, version: 0.1.7053.22118, time stamp: 0x5cc029a0
Faulting module name: msxml3.dll, version: 8.110.9600.16483, time stamp: 0x52a50e5c
Exception code: 0xc0000005
Fault offset: 0x0000000000022bd8
Faulting process id: 0x15d4
Faulting application start time: 0x01d5001d070cb40b
Faulting application path: C:\alphabackup.exe
Faulting module path: C:\Windows\System32\msxml3.dll
Report Id: 66097df3-6c10-11e9-80d3-000c29a02e5f
Faulting package full name: 
Faulting package-relative application ID: 



Application: alphabackup.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at Alphaleonis.Win32.Vss.VssBackupComponents.SetBackupSucceeded(System.Guid, System.Guid, Alphaleonis.Win32.Vss.VssComponentType, System.String, System.String, Boolean)
   at AlphaBackup.Vss.VssClient.BackupComplete()
   .....
   at AlphaBackup.Program.Main(System.String[])

The thing is that it's floating error. I have 4 fails on 12 backup jobs.

64Bit detection

I've found this project today, and stumbled upon the following sentence in the documentation:

Note that your application must be built using “Prefer 32-bit” unchecked if the Platform Target is set to Any CPU. Also note that your application must be built for 64-bit to work on a 64-bit system (or Any CPU with Prefer 32-bit off), and in 32-bit to work on a 32-bit system.

After a quick look at the source it seems to me, that the name of the loaded platform binary is built in GetPlatformSpecificAssemblyShortName() which checks Environment.Is64BitOperatingSystem.
I would suggest replacing this check with the following code:

if (IntPtr.Size == 8)
    result.Append("x64");
  else
    result.Append("x86"); 

The documentation clearly states, that this property can be used to detect the process bitness:

The value of this property is 4 in a 32-bit process, and 8 in a 64-bit process.

The VSS object was in an incorrect state for the requested operation

Hello,

I have been experimenting VSS backup for SQL storage on iSCSI disk. I am looking to leverage AlphaVSS library for that. Things are fine when I use the sample project provided here, but it did not work when I use the nuget package with my own .NET class library. In fact I am trying the same code provided in the sample project.

I am basically looking forward to write a library that can freeze the given volume(s) for few seconds, so that I can take backup of those volume. Technically, I just re-invented whats provided in https://github.com/alphaleonis/AlphaVSS-Samples/blob/develop/src/VssBackup/VssBackup.cs

With that, I am facing the following problem when I pass something to Setup('C:\')

# $b = [Demo.VssBackup]::new()
# $b.Setup('C:\local\demo.txt')
Exception calling "Setup" with "1" argument(s): "The VSS object was in an incorrect state for the requested operation."
At line:1 char:1
+ $b.Setup('C:\local\demo.txt')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : VssBadStateException

Note that I added the assembly into my powershell session to do this. FWIW, it just works with the sample project as I mentioned earlier. Although I do not know how to confirm whether the sample project works too. It just did not fail, hence assumed.

Problems running on some computers

Hi,
I am trying to use the library in Windows Server 2008 R2, and, in some computers, it fails to load AlphaVSS.x64.dll.
It does not happen in all servers, in some of them it works, in other it doesn't.
The error is this:
Impossibile caricare il file o l'assembly 'AlphaVSS.x64.dll' o una delle relative dipendenze. Impossibile trovare il modulo specificato.

That, in english, sounds like:
Could not load file or assembly 'AlphaVSS.x64.dll' or one of its dependencies. The specified module could not be found.

The dll file is placed in the same directory of AlphaShadow.exe.
On the same computer I also tried to use a previous version (1.2.4000.3) of the AlphaVSS library and the error remains the same.

Thanks
Francesco

Vss Providers

Hello,

I am trying to play a little bit with your code as I was thinking maybe to add support for the provider. I am facing issues with the implementation. I know it's not implemented but I guess you guys did some work and I'd be glad to learn from your experience. The issues I'm facing are with the interopability of .Net with the com environment. It's poorly documented and I can't interface the vss admin.

I took the sample code from Microsoft and tried to modify it, but no matter how much I tried I can't integrate .NET code into the provider. I need to somehow be able to call managed C# functions from the unmanaged VSS, or to write the entire provider in C#, which I am not sure is feasible. So far I have tried as explained above to:

  1. Write a C# com dll and load it from a native provider (changing the default implementation), but I fail to create an instance of the c# com dll in the native vss code (CoCreateInstance fails).
  2. Write a dll in C++.Net. I followed the instruction explained in https://msdn.microsoft.com/en-us/library/ms235211.aspx, but when I add even an empty managed (/clr) cpp file to the project, DllRegisterServer is not called (when registering it by calling InstallComponent of COMAdmin.COMAdminCatalog).
  3. Write a dll in C#: I managed to export the provider com interfaces to implement, but I am facing issues registering it in IVssAdmin from the C# code, in the requested format.

Any thought? I know Microsoft require the provider to be compiled as Native code. Does it mean that the only way to integrate my .NET code it to use a different process and communicate it via TCP for instance?

Any help would be appreciated!!

Thanks :)

Why does VSS Croak Sometimes?

Hi @alphaleonis ,

First off, your library has huge usage by us, indirectly, and its through these indirect usages I became aware of your great project -- you should feel very proud that multi-million dollar corporations are being powered by your software:

  1. We use MSP360's Cloudberry Online Backup to backup everything to the cloud (see screenshot below).
  2. We use Red Gate SQL Clone to create clones of our production database server backup restores. (We don't run AlphaVSS directly against the production mdf/ldf files, but restores of those files on development machines.) The Agent in the Server/Client/Agent model uses AlphaVSS.

My question to you is if you've seen the following problems

Problem 1

... sometimes these tools have problems with Volume Shadow Service. In particular, we notice sometimes that the volume stops showing up in vssadmin list volumes command, but the underlying VHD doesnt get deleted, AND when we try to delete it manually, it says that it's opened by the System process. This error message to me suggests it's not SQL Clone Agent or your library at fault, but rather Volume Shadow Service has a bug in it where it deletes the header row but doesn't process the underlying storage deletion.

Problem 2

VSS dislikes Microsoft Distributed File System Replication, and only works if you configure it for one-way replication (with read-only replicas, not multi-master replicas).

image

image

ExposeSnapshot crashes on 64bit builds

I get this error when I build my project for x64:

ExposeSnapshot: "Value does not fall within the expected range"

The way I call this method is via the following code:
IVssImplementation _vssImplementation = VssUtils.LoadImplementation(); IVssBackupComponents _backup = _vssImplementation.CreateVssBackupComponents(); _backup.InitializeForBackup(null); _backup.GatherWriterMetadata(); _backup.SetContext(VssVolumeSnapshotAttributes.Persistent | VssVolumeSnapshotAttributes.NoAutoRelease); _backup.SetBackupState(false, true, VssBackupType.Full, false); Guid MyGuid01 = _backup.StartSnapshotSet(); Guid MyGuid02 = _backup.AddToSnapshotSet(_Volume, Guid.Empty); _backup.PrepareForBackup(); _backup.DoSnapshotSet(); _backup.ExposeSnapshot(MyGuid02, null, VssVolumeSnapshotAttributes.ExposedLocally, "L:");

Is this from the GuID passed in being for 32 bit? Or is this a problem with the Windows version? It's strange because in my 32bit build that I installed on a 32bit machine the shadow copying worked fine without any errors.

AlphaVss 1.2.4003

I downloaded from Github and tried to use this with a small console application however I keep getting the error "Volume Shadow Copy Service error: An unexpected error was encountered examining the XML document. The document is missing the BACKUP_COMPONENTS element. "

It is a Vb.net project and my reference is to AlphaVSS.60.x86.dll.

I looked in both AlphaVSS.60.x86.xml and AlphaVSS.Common.xml and do not see this element. I cannot use version 1.4 because installing the VC++ 2017 components will be a big headache and I don't see 1.3 in Github. Any thoughts on what I am missing?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.