Skip to main content

Hi Community,

 For automated disaster recovery process. Need help to develop PowerShell scripts.

  1. Add backup repository
  2. Decrypt backup
  3. Import backups

Code up to now as bellow

$account = Get-VBRAmazonAccount -AccessKey "XXXXXXXXXXXX"
$connect = Connect-VBRAmazonS3Service -Account $account -RegionType Global -ServiceType CapacityTier
$bucket = Get-VBRAmazonS3Bucket -Connection $connect -Name "veeam-backup"
$folder = Get-VBRAmazonS3Folder -Name "S3-Folder" -Bucket $bucket -Connection $connect
$securepassword = Read-Host -Prompt "Enter password" -AsSecureString
$key = Add-VBREncryptionKey -Password $securepassword
Add-VBRAmazonS3Repository -Name "AmazonS3Repository" -Connection $connect -AmazonS3Folder $folder -DecryptBackups -DecryptionKey $key

But <-DecryptBackups -DecryptionKey $key> option doesnt work, 

error prompt as below

Add-VBRAmazonS3Repository : A parameter cannot be found that matches parameter name 'DecryptBackups'.

At line:1 char:99

+ ...  -Connection $connect -AmazonS3Folder $folder -DecryptBackups -Decryp ...

+                                                   ~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) Add-VBRAmazonS3Repository], ParameterBindingException

    + FullyQualifiedErrorId : NamedParameterNotFound,Veeam.Backup.PowerShell.Cmdlets.AddVBRAmazonS3Repository

Did you try to enclose your parameter variables in quotes (“)?

E.g.:

-DecryptBackups -DecryptionKey “$key”


I am definitely no AWS-expert, but it seems these parameters (-DecryptBackups -DecryptionKey) doesn't exist for Add-VBRAmazonS3Repository 

https://helpcenter.veeam.com/docs/backup/powershell/add-vbramazons3repository.html?ver=110

 


@chandrasinghe did you take the command from here?

Set-VBRAzureExternalRepository -ExternalRepository $repository -DecryptBackups -DecryptionKey $key

https://helpcenter.veeam.com/docs/backup/powershell/set-vbrazureexternalrepository.html?ver=110

because as @vNote42 said, maybe those parameters doesn’t exist for AWS.


Did you try to enclose your parameter variables in quotes (“)?

E.g.:

-DecryptBackups -DecryptionKey “$key”

do we need put variables inside quotes.


I am definitely no AWS-expert, but it seems these parameters (-DecryptBackups -DecryptionKey) doesn't exist for Add-VBRAmazonS3Repository 

https://helpcenter.veeam.com/docs/backup/powershell/add-vbramazons3repository.html?ver=110

 

I got it from here : https://helpcenter.veeam.com/docs/backup/powershell/add-vbramazons3externalrepository.html?zoom_highlight=decryptbackups&ver=110


Finally I was able to automate VM recovery via PowerShell except for credentials. 

Add backup repository to Veeam

$account = Get-VBRAmazonAccount -AccessKey "xxxxxxxxxxx"
$connect = Connect-VBRAmazonS3Service -Account $account -RegionType Global -ServiceType CapacityTier
$bucket = Get-VBRAmazonS3Bucket -Connection $connect -Name "veeam-backup"
$folder = Get-VBRAmazonS3Folder -Name "s3-folder-name" -Bucket $bucket -Connection $connect
$securepassword = Read-Host -Prompt "Enter password" -AsSecureString
$key = Add-VBREncryptionKey -Password $securepassword
Add-VBRAmazonS3Repository -Name "AmazonS3Repository" -Connection $connect -AmazonS3Folder $folder

Import Backup from S3 repository

$repository = Get-VBRObjectStorageRepository -Name "AmazonS3Repository"
$securepassword = Read-Host -Prompt "Enter password" -AsSecureString
$key = Add-VBREncryptionKey -Password $securepassword
Mount-VBRObjectStorageRepository -Repository $repository -EncryptionKey $key

Decrypt backup Jobs (Specify password)
$encryptedbackup = Get-VBRImportedEncryptedBackup -Name "backup-job" Get-VBRImportedEncryptedBackupHint -Backup $encryptedbackup Set-VBREncryptedBackupPassword -Backup $encryptedbackup -Password "xxxxxxxxxxxxx"

Setup aws credentials$creds = Get-VBRAmazonAccount -AccessKey "xxxxxxxxxx"
Set-VBRAmazonAccount -Account $creds -SecretKey "xxxxxxxxxxxxxxxxxxx"

Restore VM to AWS Ec2


$restorepoint = Get-VBRBackup -Name  "backup-job" | Get-VBRRestorePoint -Name "INF-VM" | Sort-Object –Property CreationTime –Descending | Select-Object -First 1

$account = Get-VBRAmazonAccount -Id "xxxxxxxxxxxxxxxxxx"

$region = Get-VBRAmazonEC2Region -Account $account -RegionType Global -Name "region-name"

$config = New-VBRAmazonEC2DiskConfiguration -DiskName "INF-VM-flat.vmdk" -Include -DiskType GeneralPurposeSSD

$instance = Get-VBRAmazonEC2InstanceType -Region $region -Name "ec2-type"

$vpc = Get-VBRAmazonEC2VPC -Region $region

$sgroup = Get-VBRAmazonEC2SecurityGroup -VPC $vpc -Name "security-group-name"

$subnet = Get-VBRAmazonEC2Subnet -VPC $vpc -Name "x.x.x.x/xx"

Start-VBRVMRestoreToAmazon -RestorePoint $restorepoint -Region $region -LicenseType  BYOL -InstanceType $instance -VMName "Restored VM" -DiskConfiguration $config -VPC $vpc -SecurityGroup $sgroup -Subnet $subnet -Reason "Data recovery"

 

 


its a different cmdlet. You use Add-VBRAmazonS3Repository in your script.


Thanks for sharing your solution!


Comment