Shadow Copy Wrapper?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CMM

    #1

    Shadow Copy Wrapper?

    I've been scouring the net for the last few days looking for a way to copy a
    locked file (create a shadow volume, expose it... that's it) from within my
    program. I'm aware of the kludgy vshadow.exe commandline tool, but what I
    really need is to be able to do it in managed code or via API's. I'm also
    aware of the VSS SDK so I don't need a pointer to them.... just wondering if
    anyone has had experience with this.

  • Michael Nemtsev [MVP]

    #2
    Re: Shadow Copy Wrapper?

    Hello CMM,

    if u aware about VSS SDK, u should noted that there is a sample of using it

    did u check how that sample meets your needs?

    ---
    WBR,
    Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo


    CI've been scouring the net for the last few days looking for a way to
    Ccopy a locked file (create a shadow volume, expose it... that's it)
    Cfrom within my program. I'm aware of the kludgy vshadow.exe
    Ccommandline tool, but what I really need is to be able to do it in
    Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
    Cneed a pointer to them.... just wondering if anyone has had
    Cexperience with this.
    C>


    Comment

    • Willy Denoyette [MVP]

      #3
      Re: Shadow Copy Wrapper?

      "CMM" <cmm@nospam.com wrote in message
      news:196DED00-295B-40D9-BA29-93ED8F6E9B4F@mi crosoft.com...
      I've been scouring the net for the last few days looking for a way to copy
      a locked file (create a shadow volume, expose it... that's it) from within
      my program. I'm aware of the kludgy vshadow.exe commandline tool, but what
      I really need is to be able to do it in managed code or via API's. I'm
      also aware of the VSS SDK so I don't need a pointer to them.... just
      wondering if anyone has had experience with this.
      >

      The VSS API's are a set of COM and C++ interfaces, none of them are directly
      accessible from C#, so you'll have to write a wrapper in C++/CLI to be able
      to access them from pure managed code.
      Note however that using VSS only because you need to copy a locked file is
      overkill, you can achieve the same functionality by using PInvoke to call
      some Win32 API's.

      First you need to open the file using Win32 "CreateFile " API with:
      dwDesiredACcess = 0
      dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRIT E
      and dwFlagsAndAttri butes = FILE_FLAG_BACKU P_SEMANTICS set.
      The file handle returned can be used to call the "Kernel32" Backup API's
      like "BackupRead ", "BackupSeek " etc....
      Note that this all requires the right privileges (SeBackupPrivil ege) for the
      caller!

      Willy.

      Comment

      • CMM

        #4
        Re: Shadow Copy Wrapper?

        I was under the impression that the samples are C++ and not exactly portable
        to the managed world. It's a shame too... because VShadow.exe... with a
        little effort on the VSS team could probably be retooled into a useful
        class.


        "Michael Nemtsev [MVP]" <nemtsev@msn.co mwrote in message
        news:3d9fba1a1a 30e8c9f52e51e6d b50@msnews.micr osoft.com...
        Hello CMM,
        >
        if u aware about VSS SDK, u should noted that there is a sample of using
        it
        >
        did u check how that sample meets your needs?
        >
        ---
        WBR, Michael Nemtsev [.NET/C# MVP] :: blog:

        "The greatest danger for most of us is not that our aim is too high and we
        miss it, but that it is too low and we reach it" (c) Michelangelo
        >
        CI've been scouring the net for the last few days looking for a way to
        Ccopy a locked file (create a shadow volume, expose it... that's it)
        Cfrom within my program. I'm aware of the kludgy vshadow.exe
        Ccommandline tool, but what I really need is to be able to do it in
        Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
        Cneed a pointer to them.... just wondering if anyone has had
        Cexperience with this.
        C>
        >

        Comment

        • Willy Denoyette [MVP]

          #5
          Re: Shadow Copy Wrapper?

          The VSS team is not owning the SDK and it's samples, nor do they care about
          managed code, the API is exposed through COM and C++ interfaces just like
          the VSS Service. Writing a managed wrapper in C++/CLI isn't that hard
          anyway. Note that as I said in another reply, you don't need VSS for this at
          all.

          Willy.



          "CMM" <cmm@nospam.com wrote in message
          news:8EC5E46B-8521-45C5-936D-961122E5C44A@mi crosoft.com...
          >I was under the impression that the samples are C++ and not exactly
          >portable to the managed world. It's a shame too... because VShadow.exe...
          >with a little effort on the VSS team could probably be retooled into a
          >useful class.
          >
          >
          "Michael Nemtsev [MVP]" <nemtsev@msn.co mwrote in message
          news:3d9fba1a1a 30e8c9f52e51e6d b50@msnews.micr osoft.com...
          >Hello CMM,
          >>
          >if u aware about VSS SDK, u should noted that there is a sample of using
          >it
          >>
          >did u check how that sample meets your needs?
          >>
          >---
          >WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
          >http://spaces.live.com/laflour
          >"The greatest danger for most of us is not that our aim is too high and
          >we miss it, but that it is too low and we reach it" (c) Michelangelo
          >>
          >CI've been scouring the net for the last few days looking for a way to
          >Ccopy a locked file (create a shadow volume, expose it... that's it)
          >Cfrom within my program. I'm aware of the kludgy vshadow.exe
          >Ccommandline tool, but what I really need is to be able to do it in
          >Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
          >Cneed a pointer to them.... just wondering if anyone has had
          >Cexperience with this.
          >C>
          >>
          >

          Comment

          • CMM

            #6
            Re: Shadow Copy Wrapper?

            I don't need VSS at all? So BackupRead will alert the file's owner to flush
            the file like VSS does? What if the actual copying is being done by code
            other than mine? Ideally, I want to create the snapshot, pass the exposed
            volume to the component to handle the rest, etc. Anyway, I was looking for a
            simple solution. Looks like calling vshadow.exe and scripting it will end up
            being the way to go. Shame.

            "Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
            news:uRdSvPtJIH A.5400@TK2MSFTN GP04.phx.gbl...
            The VSS team is not owning the SDK and it's samples, nor do they care
            about managed code, the API is exposed through COM and C++ interfaces just
            like the VSS Service. Writing a managed wrapper in C++/CLI isn't that hard
            anyway. Note that as I said in another reply, you don't need VSS for this
            at all.
            >
            Willy.
            >
            >
            >
            "CMM" <cmm@nospam.com wrote in message
            news:8EC5E46B-8521-45C5-936D-961122E5C44A@mi crosoft.com...
            >>I was under the impression that the samples are C++ and not exactly
            >>portable to the managed world. It's a shame too... because VShadow.exe...
            >>with a little effort on the VSS team could probably be retooled into a
            >>useful class.
            >>
            >>
            >"Michael Nemtsev [MVP]" <nemtsev@msn.co mwrote in message
            >news:3d9fba1a1 a30e8c9f52e51e6 db50@msnews.mic rosoft.com...
            >>Hello CMM,
            >>>
            >>if u aware about VSS SDK, u should noted that there is a sample of using
            >>it
            >>>
            >>did u check how that sample meets your needs?
            >>>
            >>---
            >>WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
            >>http://spaces.live.com/laflour
            >>"The greatest danger for most of us is not that our aim is too high and
            >>we miss it, but that it is too low and we reach it" (c) Michelangelo
            >>>
            >>CI've been scouring the net for the last few days looking for a way to
            >>Ccopy a locked file (create a shadow volume, expose it... that's it)
            >>Cfrom within my program. I'm aware of the kludgy vshadow.exe
            >>Ccommandlin e tool, but what I really need is to be able to do it in
            >>Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
            >>Cneed a pointer to them.... just wondering if anyone has had
            >>Cexperience with this.
            >>C>
            >>>
            >>
            >
            >

            Comment

            • Willy Denoyette [MVP]

              #7
              Re: Shadow Copy Wrapper?

              "CMM" <cmm@nospam.com wrote in message
              news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@mi crosoft.com...
              >I don't need VSS at all? So BackupRead will alert the file's owner to flush
              >the file like VSS does? What if the actual copying is being done by code
              >other than mine? Ideally, I want to create the snapshot, pass the exposed
              >volume to the component to handle the rest, etc. Anyway, I was looking for
              >a simple solution. Looks like calling vshadow.exe and scripting it will end
              >up being the way to go. Shame.
              >
              "Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
              news:uRdSvPtJIH A.5400@TK2MSFTN GP04.phx.gbl...
              >The VSS team is not owning the SDK and it's samples, nor do they care
              >about managed code, the API is exposed through COM and C++ interfaces
              >just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
              >that hard anyway. Note that as I said in another reply, you don't need
              >VSS for this at all.
              >>
              >Willy.
              >>
              >>
              >>
              >"CMM" <cmm@nospam.com wrote in message
              >news:8EC5E46 B-8521-45C5-936D-961122E5C44A@mi crosoft.com...
              >>>I was under the impression that the samples are C++ and not exactly
              >>>portable to the managed world. It's a shame too... because VShadow.exe...
              >>>with a little effort on the VSS team could probably be retooled into a
              >>>useful class.
              >>>
              >>>
              >>"Michael Nemtsev [MVP]" <nemtsev@msn.co mwrote in message
              >>news:3d9fba1a 1a30e8c9f52e51e 6db50@msnews.mi crosoft.com...
              >>>Hello CMM,
              >>>>
              >>>if u aware about VSS SDK, u should noted that there is a sample of
              >>>using it
              >>>>
              >>>did u check how that sample meets your needs?
              >>>>
              >>>---
              >>>WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
              >>>http://spaces.live.com/laflour
              >>>"The greatest danger for most of us is not that our aim is too high and
              >>>we miss it, but that it is too low and we reach it" (c) Michelangelo
              >>>>
              >>>CI've been scouring the net for the last few days looking for a way
              >>>to
              >>>Ccopy a locked file (create a shadow volume, expose it... that's it)
              >>>Cfrom within my program. I'm aware of the kludgy vshadow.exe
              >>>Ccommandli ne tool, but what I really need is to be able to do it in
              >>>Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
              >>>Cneed a pointer to them.... just wondering if anyone has had
              >>>Cexperienc e with this.
              >>>C>
              >>>>
              >>>
              >>
              >>
              >

              Comment

              • Willy Denoyette [MVP]

                #8
                Re: Shadow Copy Wrapper?

                VSS can't alert the owning program unless this one implements the VSWriter
                interfaces. That means that the application needs to be modified for this.
                When the application does not implement VSWriter, the File System will
                simply be "alerted" to flush the FS buffers, but this is no guaranteed to be
                free of incomplete I/Writer operations and data corruption, the shadow image
                is said to be in a "Crash-Consistent state". If you need application
                recovery state, you have to implement a writer in the application owning the
                file(s).

                Willy.


                "CMM" <cmm@nospam.com wrote in message
                news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@mi crosoft.com...
                >I don't need VSS at all? So BackupRead will alert the file's owner to flush
                >the file like VSS does? What if the actual copying is being done by code
                >other than mine? Ideally, I want to create the snapshot, pass the exposed
                >volume to the component to handle the rest, etc. Anyway, I was looking for
                >a simple solution. Looks like calling vshadow.exe and scripting it will end
                >up being the way to go. Shame.
                >
                "Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
                news:uRdSvPtJIH A.5400@TK2MSFTN GP04.phx.gbl...
                >The VSS team is not owning the SDK and it's samples, nor do they care
                >about managed code, the API is exposed through COM and C++ interfaces
                >just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
                >that hard anyway. Note that as I said in another reply, you don't need
                >VSS for this at all.
                >>
                >Willy.
                >>
                >>
                >>
                >"CMM" <cmm@nospam.com wrote in message
                >news:8EC5E46 B-8521-45C5-936D-961122E5C44A@mi crosoft.com...
                >>>I was under the impression that the samples are C++ and not exactly
                >>>portable to the managed world. It's a shame too... because VShadow.exe...
                >>>with a little effort on the VSS team could probably be retooled into a
                >>>useful class.
                >>>
                >>>
                >>"Michael Nemtsev [MVP]" <nemtsev@msn.co mwrote in message
                >>news:3d9fba1a 1a30e8c9f52e51e 6db50@msnews.mi crosoft.com...
                >>>Hello CMM,
                >>>>
                >>>if u aware about VSS SDK, u should noted that there is a sample of
                >>>using it
                >>>>
                >>>did u check how that sample meets your needs?
                >>>>
                >>>---
                >>>WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
                >>>http://spaces.live.com/laflour
                >>>"The greatest danger for most of us is not that our aim is too high and
                >>>we miss it, but that it is too low and we reach it" (c) Michelangelo
                >>>>
                >>>CI've been scouring the net for the last few days looking for a way
                >>>to
                >>>Ccopy a locked file (create a shadow volume, expose it... that's it)
                >>>Cfrom within my program. I'm aware of the kludgy vshadow.exe
                >>>Ccommandli ne tool, but what I really need is to be able to do it in
                >>>Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
                >>>Cneed a pointer to them.... just wondering if anyone has had
                >>>Cexperienc e with this.
                >>>C>
                >>>>
                >>>
                >>
                >>
                >

                Comment

                • CMM

                  #9
                  Re: Shadow Copy Wrapper?

                  Yes, I'm aware of that. The question remains: there is no way, no working
                  examples, and no experience with using C# or VB.NET to create and expose a
                  shadow snapshot of a volume, right?

                  "Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
                  news:eMxTENwJIH A.536@TK2MSFTNG P06.phx.gbl...
                  VSS can't alert the owning program unless this one implements the VSWriter
                  interfaces. That means that the application needs to be modified for this.
                  When the application does not implement VSWriter, the File System will
                  simply be "alerted" to flush the FS buffers, but this is no guaranteed to
                  be free of incomplete I/Writer operations and data corruption, the shadow
                  image is said to be in a "Crash-Consistent state". If you need application
                  recovery state, you have to implement a writer in the application owning
                  the file(s).
                  >
                  Willy.
                  >
                  >
                  "CMM" <cmm@nospam.com wrote in message
                  news:809EF727-4CB5-4DF6-9459-F5EB4B37F2D0@mi crosoft.com...
                  >>I don't need VSS at all? So BackupRead will alert the file's owner to
                  >>flush the file like VSS does? What if the actual copying is being done by
                  >>code other than mine? Ideally, I want to create the snapshot, pass the
                  >>exposed volume to the component to handle the rest, etc. Anyway, I was
                  >>looking for a simple solution. Looks like calling vshadow.exe and
                  >>scripting it will end up being the way to go. Shame.
                  >>
                  >"Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
                  >news:uRdSvPtJI HA.5400@TK2MSFT NGP04.phx.gbl.. .
                  >>The VSS team is not owning the SDK and it's samples, nor do they care
                  >>about managed code, the API is exposed through COM and C++ interfaces
                  >>just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
                  >>that hard anyway. Note that as I said in another reply, you don't need
                  >>VSS for this at all.
                  >>>
                  >>Willy.
                  >>>
                  >>>
                  >>>
                  >>"CMM" <cmm@nospam.com wrote in message
                  >>news:8EC5E4 6B-8521-45C5-936D-961122E5C44A@mi crosoft.com...
                  >>>>I was under the impression that the samples are C++ and not exactly
                  >>>>portable to the managed world. It's a shame too... because
                  >>>>VShadow.exe ... with a little effort on the VSS team could probably be
                  >>>>retooled into a useful class.
                  >>>>
                  >>>>
                  >>>"Michael Nemtsev [MVP]" <nemtsev@msn.co mwrote in message
                  >>>news:3d9fba1 a1a30e8c9f52e51 e6db50@msnews.m icrosoft.com...
                  >>>>Hello CMM,
                  >>>>>
                  >>>>if u aware about VSS SDK, u should noted that there is a sample of
                  >>>>using it
                  >>>>>
                  >>>>did u check how that sample meets your needs?
                  >>>>>
                  >>>>---
                  >>>>WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
                  >>>>http://spaces.live.com/laflour
                  >>>>"The greatest danger for most of us is not that our aim is too high
                  >>>>and we miss it, but that it is too low and we reach it" (c)
                  >>>>Michelangel o
                  >>>>>
                  >>>>CI've been scouring the net for the last few days looking for a way
                  >>>>to
                  >>>>Ccopy a locked file (create a shadow volume, expose it... that's it)
                  >>>>Cfrom within my program. I'm aware of the kludgy vshadow.exe
                  >>>>Ccommandlin e tool, but what I really need is to be able to do it in
                  >>>>Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
                  >>>>Cneed a pointer to them.... just wondering if anyone has had
                  >>>>Cexperien ce with this.
                  >>>>C>
                  >>>>>
                  >>>>
                  >>>
                  >>>
                  >>
                  >
                  >

                  Comment

                  • Willy Denoyette [MVP]

                    #10
                    Re: Shadow Copy Wrapper?

                    That's right because like I have said, the VSS interfaces are not directly
                    usable from "pure" managed code, you have to write a wrapper in C++/CLI
                    (mixed managed unmanaged code) for this.

                    Willy.

                    "CMM" <cmm@nospam.com wrote in message
                    news:90A2D81A-41E3-433F-BB64-9865C55B58D3@mi crosoft.com...
                    Yes, I'm aware of that. The question remains: there is no way, no working
                    examples, and no experience with using C# or VB.NET to create and expose a
                    shadow snapshot of a volume, right?
                    >
                    "Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
                    news:eMxTENwJIH A.536@TK2MSFTNG P06.phx.gbl...
                    >VSS can't alert the owning program unless this one implements the
                    >VSWriter interfaces. That means that the application needs to be modified
                    >for this. When the application does not implement VSWriter, the File
                    >System will simply be "alerted" to flush the FS buffers, but this is no
                    >guaranteed to be free of incomplete I/Writer operations and data
                    >corruption, the shadow image is said to be in a "Crash-Consistent state".
                    >If you need application recovery state, you have to implement a writer in
                    >the application owning the file(s).
                    >>
                    >Willy.
                    >>
                    >>
                    >"CMM" <cmm@nospam.com wrote in message
                    >news:809EF72 7-4CB5-4DF6-9459-F5EB4B37F2D0@mi crosoft.com...
                    >>>I don't need VSS at all? So BackupRead will alert the file's owner to
                    >>>flush the file like VSS does? What if the actual copying is being done by
                    >>>code other than mine? Ideally, I want to create the snapshot, pass the
                    >>>exposed volume to the component to handle the rest, etc. Anyway, I was
                    >>>looking for a simple solution. Looks like calling vshadow.exe and
                    >>>scripting it will end up being the way to go. Shame.
                    >>>
                    >>"Willy Denoyette [MVP]" <willy.denoyett e@telenet.bewro te in message
                    >>news:uRdSvPtJ IHA.5400@TK2MSF TNGP04.phx.gbl. ..
                    >>>The VSS team is not owning the SDK and it's samples, nor do they care
                    >>>about managed code, the API is exposed through COM and C++ interfaces
                    >>>just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
                    >>>that hard anyway. Note that as I said in another reply, you don't need
                    >>>VSS for this at all.
                    >>>>
                    >>>Willy.
                    >>>>
                    >>>>
                    >>>>
                    >>>"CMM" <cmm@nospam.com wrote in message
                    >>>news:8EC5E46 B-8521-45C5-936D-961122E5C44A@mi crosoft.com...
                    >>>>>I was under the impression that the samples are C++ and not exactly
                    >>>>>portable to the managed world. It's a shame too... because
                    >>>>>VShadow.ex e... with a little effort on the VSS team could probably be
                    >>>>>retooled into a useful class.
                    >>>>>
                    >>>>>
                    >>>>"Michael Nemtsev [MVP]" <nemtsev@msn.co mwrote in message
                    >>>>news:3d9fba 1a1a30e8c9f52e5 1e6db50@msnews. microsoft.com.. .
                    >>>>>Hello CMM,
                    >>>>>>
                    >>>>>if u aware about VSS SDK, u should noted that there is a sample of
                    >>>>>using it
                    >>>>>>
                    >>>>>did u check how that sample meets your needs?
                    >>>>>>
                    >>>>>---
                    >>>>>WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
                    >>>>>http://spaces.live.com/laflour
                    >>>>>"The greatest danger for most of us is not that our aim is too high
                    >>>>>and we miss it, but that it is too low and we reach it" (c)
                    >>>>>Michelange lo
                    >>>>>>
                    >>>>>CI've been scouring the net for the last few days looking for a way
                    >>>>>to
                    >>>>>Ccopy a locked file (create a shadow volume, expose it... that's
                    >>>>>it)
                    >>>>>Cfrom within my program. I'm aware of the kludgy vshadow.exe
                    >>>>>Ccommandli ne tool, but what I really need is to be able to do it in
                    >>>>>Cmanaged code or via API's. I'm also aware of the VSS SDK so I
                    >>>>>don't
                    >>>>>Cneed a pointer to them.... just wondering if anyone has had
                    >>>>>Cexperienc e with this.
                    >>>>>C>
                    >>>>>>
                    >>>>>
                    >>>>
                    >>>>
                    >>>
                    >>
                    >>
                    >

                    Comment

                    Working...