Software-based VM-centric and flash-friendly VM storage + free version
Moderators: anton (staff), art (staff), Max (staff), Anatoly (staff)
-
chell
- Posts: 48
- Joined: Mon Dec 11, 2017 1:19 am
Mon Mar 05, 2018 3:39 am
Hi
I'm trying to use the create snapshot via the sample powershell script.
I keep getting the error "External component has thrown an exception"
The script is connecting to the star wind server and if I # out the new-snapshot command it does list all of the snapshots current there, so the device name is correct.
Starwind 8.0.0.11818
Any ideas?
Is mounting a snapshot via powershell possible yet?
Thanks
Code: Select all
Import-Module StarWindX
$server = New-SWServer -host 192.168.12.1 -port 3261 -user root -password starwind
try
{
#Connection
$server.Connect()
if ( $server.Connected )
{
$deviceName = "lsfs4"
#
# Create snapshot
#
New-Snapshot $server $deviceName "snapshotName1" "snapshotDescription"
Write-Host "Snapshot created!" -foreground yellow
Write-Host ""
#
# get snapshots list
#
foreach($device in $server.Devices)
{
if ( $device.name -eq $deviceName)
{
if ( $device.IsSnapshotsSupported )
{
foreach($snapshot in $device.Snapshots)
{
Write-Host "Snapshot Id: $($snapshot.Id) Name: $($snapshot.name) Date: $($snapshot.Date)"
}
}
break;
}
}
}
$server.Disconnect()
}
catch
{
Write-Host "Exception $($_.Exception.Message)" -foreground red
$server.Disconnect()
}
-
Oleg(staff)
- Staff
- Posts: 568
- Joined: Fri Nov 24, 2017 7:52 am
Tue Mar 06, 2018 10:40 am
Hi chell,
Is mounting a snapshot via powershell possible yet?
No, this option is not available via PowerShell at the current, 8.0.0.11818 build, yet.
-
chell
- Posts: 48
- Joined: Mon Dec 11, 2017 1:19 am
Thu Mar 08, 2018 3:23 am
Feature request. The ability to roll back to a snapshot would be really useful.
Mounting a snapshot is handy if you want to copy a few files. but its extremely time consuming if you need to copy a large amount of data.
For example a ransomware attack. I would revert the drive back to the last snapshot then use the backups to restore the changes. This would be much quicker than restoring all of the data from backups or copying data from a mounted snapshot
-
Oleg(staff)
- Staff
- Posts: 568
- Joined: Fri Nov 24, 2017 7:52 am
Thu Mar 08, 2018 10:33 am
Yes, I have already sent your request to our R&D team. This feature will be added in the further StarWind builds.
-
Sekkmer
- Posts: 29
- Joined: Thu Mar 08, 2018 12:11 pm
Thu Mar 08, 2018 1:07 pm
I run into the same problem with the current build (11818) but if you run the script on the previous build (11456) it is working fine even if the server is running with (11818)
regarding the mounting of a snapshot, you should look into the original script which can be found here:
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\StarWindX\LSFS.ps1
you just need to write a script which creates the same LSFSDevice as the original then you just add these parameters before the creation:
(device.File does not work in 11456 for LSFSDevices, use device.GetPropertyValue("DataPath"))
$param.AppendParam("DataPath", device.File);
$param.AppendParam("SnapshotID", snapshot.Offset);
$param.AppendParam("SnapshotDisabled", "yes");
Edit:
I just tested that you can create a snapshot in build 11818 with server.ExecuteCommand(STARWIND_COMMAND_TYPE.STARWIND_COMMAND, "CreateSnapshot", param).
For this to work add the following parameters:
$param.AppendParam("deviceID", device.DeviceId);
$param.AppendParam("snapshotName", "Name Of Your New Snapshot");
you can add an additional parameter: "snapshotDescription"
Last edited by
Sekkmer on Fri Mar 09, 2018 12:56 pm, edited 1 time in total.
-
chell
- Posts: 48
- Joined: Mon Dec 11, 2017 1:19 am
Tue Mar 13, 2018 6:56 pm
Hi Sekkmer
Thank you for your reply.
Is it possible for you to post a copy of your test script? I'm having troubles changing the script above to work with server.ExecuteCommand(STARWIND_COMMAND_TYPE.STARWIND_COMMAND, "CreateSnapshot", param)
much appreciated
Sekkmer wrote:I run into the same problem with the current build (11818) but if you run the script on the previous build (11456) it is working fine even if the server is running with (11818)
regarding the mounting of a snapshot, you should look into the original script which can be found here:
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\StarWindX\LSFS.ps1
you just need to write a script which creates the same LSFSDevice as the original then you just add these parameters before the creation:
(device.File does not work in 11456 for LSFSDevices, use device.GetPropertyValue("DataPath"))
$param.AppendParam("DataPath", device.File);
$param.AppendParam("SnapshotID", snapshot.Offset);
$param.AppendParam("SnapshotDisabled", "yes");
Edit:
I just tested that you can create a snapshot in build 11818 with server.ExecuteCommand(STARWIND_COMMAND_TYPE.STARWIND_COMMAND, "CreateSnapshot", param).
For this to work add the following parameters:
$param.AppendParam("deviceID", device.DeviceId);
$param.AppendParam("snapshotName", "Name Of Your New Snapshot");
you can add an additional parameter: "snapshotDescription"
-
Sekkmer
- Posts: 29
- Joined: Thu Mar 08, 2018 12:11 pm
Thu Mar 15, 2018 12:08 pm
the line should have been: " $server.ExecuteCommand(0, "CreateSnapshot", $params)", I use C# for my StarWind project and I just copied the line from there.
I wrote the script for you:
Code: Select all
function New-SnapshotFixed( [parameter(Mandatory=$true, HelpMessage="StarWind server object", Position=0)]
[ValidateNotNullOrEmpty()]
$server,
[parameter(Mandatory=$true, Position=1)]
[ValidateNotNullOrEmpty()]
$deviceName,
[parameter(Mandatory=$true, Position=2)]
[System.String]$snapshotName,
[parameter(Mandatory=$false, Position=3)]
[System.String]$snapshotDescription )
{
if( !$server.Connected )
{
$server.Connect()
}
$device = Get-Device $server -name $deviceName
if ( !$device )
{
throw "Device with specified name not found"
}
if ( $device.IsSnapshotsSupported )
{
$params = new-object -ComObject StarWindX.Parameters
$params.AppendParam("deviceID", $device.DeviceId)
$params.AppendParam("snapshotName", $snapshotName)
$params.AppendParam("snapshotDescription", $snapshotDescription)
$server.ExecuteCommand(0, "CreateSnapshot", $params)
}
else
{
throw "Device doesn't support snapshots"
}
}