question

KalaimaniThirupathi-5306 avatar image
0 Votes"
KalaimaniThirupathi-5306 asked SadiqhAhmed-MSFT commented

Get Available Azure Backup Restore Point using powershell

Dear All,

I was trying a lot to get the available restore points in Azure backup can someone help me with this.


trying with the below one but it's not working


$subscriptions = Get-AzSubscription
ForEach ($Subscription in $Subscriptions) {
Set-AzContext -SubscriptionId $Subscription.Id
$RCvaults = get-azrecoveryservicesvault
ForEach ($RCvault in $RCvaults)
{
Set-AzRecoveryServicesVaultContext -Vault $RCvault
$vault = Get-AzRecoveryServicesVault -ResourceGroupName $RCvault.ResourceGroupName -Name $RCvault.Name
$StartDate = (Get-Date).AddDays(-30
$EndDate = Get-Date
$Container = Get-AzRecoveryServicesBackupContainer -ContainerType AzureVM -Status Registered -VaultId $vault.ID
$BackupItem = Get-AzRecoveryServicesBackupItem -ContainerType AzureVM -VaultId $vault.ID
$RP = Get-AzRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $Startdate.ToUniversalTime() -EndDate $Enddate.ToUniversalTime() -VaultId $vault.ID
}
}

azure-backup
· 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Dear All,

I was looking only to get the available restore point more than 30 days old in the recovery service vault.

0 Votes 0 ·

I was looking only to get the available restore point more than 30 days old in the recovery service vault.

0 Votes 0 ·

I was looking only to get the available restore point more than 30 days old in the recovery service vault.

0 Votes 0 ·

Can you someone help me with this please

0 Votes 0 ·

@KalaimaniThirupathi-5306 Sorry for the delay!

Basically, we can’t get ALL RPs at once. There has to be a start time and end time. If you don’t give them, we assume last 30 days. If you give them, we try to honor it. So, please let us know what is the actual requirement. Then we can figure out the usage of PS/CLI commands with the right start time and end time.


If the response helped, do "Accept Answer" and up-vote it

0 Votes 0 ·

Hi SadiqhAhmed-MSFT - trying to get the old restore point more than 30 days old for select subscription

0 Votes 0 ·

I was looking for someone help badly here.

I have posted multiple questions but have not received none of them from Microsoft

0 Votes 0 ·
SadiqhAhmed-MSFT avatar image SadiqhAhmed-MSFT KalaimaniThirupathi-5306 ·

@KalaimaniThirupathi-5306 I have replied to your question. What exact help are you looking for? ![98211-image.png][1] [1]: /answers/storage/attachments/98211-image.png

0 Votes 0 ·

trying to get the old restore point more than 30 days old or available restore point in the Recovery Services Vault for select subscription

0 Votes 0 ·
Show more comments

1 Answer

JMattes avatar image
0 Votes"
JMattes answered

I see some syntaxial issues so here is a chunk of code I used to take backups from an RSV and move them to a less expensive storage account. I used this for a client who had created several backup plans on a 5 TB premium storage account and realized that was a bad idea after his bill tripled.

$RG = 'StorageSnapTest'
$RSV = 'Backups-rsv'
$RSV_RG = 'Management-rg'

$stgSrc = 'stgautomationsource'
$stgDst = 'stgautomationdest'
$target = 'filesrecovered'

$vault = Get-AzRecoveryServicesVault -ResourceGroupName $RSV_RG -Name $RSV
$container = Get-AzRecoveryServicesBackupContainer -ContainerType AzureStorage -Status Registered -VaultId $vault.ID -FriendlyName $stgSrc
$backupItem = Get-AzRecoveryServicesBackupItem -Container $container -WorkloadType AzureFiles -VaultId $vault.ID

$rp = (Get-AzRecoveryServicesBackupRecoveryPoint -Item $backupItem -VaultId $vault.ID)

$context_acct = (Get-AzStorageAccount -ResourceGroupName $RG -Name $stgDst).Context

foreach($snap in $rp) {
[string] $uri = $snap.FileShareSnapshotUri
[string] $restoreFolder = ($uri.Substring($uri.IndexOf("sharesnapshot=")).Replace(':', '_'))

 try { 
     (Get-AzStorageShare -Context $context_acct -Name $target) | New-AzStorageDirectory -Path $restoreFolder | Out-Null
 } catch {}

 $restoreJob = Restore-AzRecoveryServicesBackupItem -VaultLocation $vault.Location -RecoveryPoint $snap -TargetStorageAccountName $stgDst -TargetFileShareName $target -TargetFolder $restoreFolder -ResolveConflict Overwrite -VaultId $vault.ID

}


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.