Copy a volume using Java

I am currently creating a backup application where we need a way to read files that are used by other applications, and we also want to minimize the lock that we take on user files. Using the Window Volume Shadow Copy Service seems to us to be an ideal way to achieve this.

However, our problem is that we are using Java. Is there any easy way to implement this anyway (either using some kind of library, or even with some CLIs)?

+6
source share
3 answers

I have done this before.

The easiest way we found out is to build 4 versions of vshadow.exe (a demo tool for quickly starting from VSS from the Microsoft website): one for each target form in XP / later and x86 / x64. VShadow basically allows you to create or destroy a snapshot and retrieve a Path that looks like this:

\\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopyXX , which you can use to replace the letter of your drive ( D: for example), which works with the JAVA API . The VShadow version of the VSS SDK is read and written, it is not the same version as exe, which you can download directly, read-only.

Then, in Java, it is easy to write two CLI shells with a unified interface (to handle two different VShadow actions between XP and later).

Good luck.

+7
source

So, I know little about VSS, but in terms of accessing the native Windows APIs with Java, I would look at JNA. You may well find that someone has already ported the corresponding API definitions to JNA.

+2
source

Hmm ... doing this through Java can be complex and very error prone

One easy way to do this is to write a small native DLL that does what you want to use VSS using the VSS API.

And then using either C # pInvoke or C ++ / CLI ... and then you can use any other CLI compatible language

+1
source

Source: https://habr.com/ru/post/910850/


All Articles