Forum Discussion
Patrick Sanouiller
Jul 16, 2019Brass Contributor
AzureFiles backup restore
Hello,
I created AzureFiles backup and want to restore So I use this script:
Select-AzureRmSubscription -SubscriptionId $AzureSubscriptionId
$Vault = Get-AzureRmRecoveryServicesVault -Name $BackupVault
Set-AzureRmRecoveryServicesVaultContext -Vault $Vault
$NamedContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureStorage –Status Registered -FriendlyName $FileShareName
$BackupItem = Get-AzureRmRecoveryServicesBackupItem –Container $NamedContainer –WorkloadType AzureFiles
$StartDate = (Get-Date).AddDays(-7)
$EndDate = Get-Date
$RecoveryPoint = Get-AzureRmRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime()
$RestoreJob = Restore-AzureRmRecoveryServicesBackupItem -RecoveryPoint $RecoveryPoint[0] -StorageAccountName $StorageAccount -StorageAccountResourceGroupName $ResourceGroupName
But I get an error:
Get-AzureRmRecoveryServicesBackupRecoveryPoint : Cannot convert 'System.Object[]' to the type 'Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.ItemBase' required by parameter 'Item'. Specified method is not supported. At line:46 char:71 + ... -AzureRmRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartD ... + ~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-AzureRmReco...upRecoveryPoint], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmR ecoveryServicesBackupRecoveryPoint
How to solve this?
- Manidurai MohanamariappanIron Contributor
Based on the error message $BackupItem is array value, so use foreach loop in the script.
- DarrickBrass Contributor
1. Does $NamedContainer have an object reference?
2. Does $BackupItem have an object reference?