Skip to content

Commit e352b06

Browse files
committed
Fix restore volume powershell cmdlets
1 parent bbcdef4 commit e352b06

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/VeeamBackupProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public boolean restoreVMFromBackup(VirtualMachine vm, String backupUuid, String
196196
@Override
197197
public Pair<Boolean, String> restoreBackedUpVolume(long zoneId, String backupUuid, String restorePointId,
198198
String volumeUuid, String hostIp, String dataStoreUuid) {
199+
199200
return getClient(zoneId).restoreVMToDifferentLocation(restorePointId, hostIp, dataStoreUuid);
200201
}
201202

plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ public Pair<Boolean, String> restoreVMToDifferentLocation(String restorePointId,
640640
final String restoreLocation = "CS-RSTR-" + UUID.randomUUID().toString();
641641
final String datastoreId = dataStoreUuid.replace("-","");
642642
final List<String> cmds = Arrays.asList(
643-
String.format("$point = Get-VBRRestorePoint | where {$_.Id -eq \"%s\"}", restorePointId),
643+
"$points = Get-VBRRestorePoint",
644+
String.format("foreach($point in $points) { if ($point.Id -eq '%s') { break; } }",restorePointId),
644645
String.format("$server = Get-VBRServer -Name \"%s\"", hostIp),
645646
String.format("$ds = Find-VBRViDatastore -Server:$server -Name \"%s\"", datastoreId),
646647
String.format("Start-VBRRestoreVM -RestorePoint:$point -Server:$server -Datastore:$ds -VMName \"%s\"", restoreLocation)

plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.List;
2929
import java.util.Map;
3030

31+
import com.cloud.utils.Pair;
3132
import org.apache.cloudstack.backup.BackupPolicy;
3233
import org.apache.cloudstack.backup.VMBackup;
3334
import org.apache.cloudstack.backup.veeam.api.Job;
@@ -99,4 +100,9 @@ public void testVeeamPS() throws Exception {
99100
Job j = client.listJob("ZONE1-GOLD_clone1");
100101
}
101102

103+
public void testRestoreVolume() {
104+
client.setVeeamSshCredentials("10.2.2.89", "administrator", "P@ssword123");
105+
Pair<Boolean, String> booleanStringPair = client.restoreVMToDifferentLocation("362fcba7-283b-4416-9763-55ec59bd1285", "10.2.2.9", "24abcb8f-4211-374f-a2e1-e5c0b7e88a2d");
106+
booleanStringPair.first();
107+
}
102108
}

0 commit comments

Comments
 (0)