page_type | languages | products | description | ||
---|---|---|---|---|---|
sample |
|
|
Automates top asks using PowerShell for Azure Backup archive feature |
Automate archive move using PowerShell for Azure Backup
Runbooks for Archive move
-
Run Latest Version of Powershell in administrator mode
-
Run the following command to set the execution policy (this allows permission for scripts to be run)
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
-
Download the scripts
-
Use the following commands for installation and setup
cd <Location of the script> install-module -name Az.RecoveryServices -Repository PSGallery -AllowClobber -Force
-
Connect to Azure using the "Connect-AzAccount" cmdlet.
-
Run the scripts
Download viewArchivableRPs
This sample script is used to view all the archivable recovery points associated with a backup item between any time range.
- Subscription
- ResourceGroupName
- VaultName
- ItemType – {AzureVM,MSSQL)
- StartDate = (Get-Date).AddDays(-x).ToUniversalTime()
- EndDate = (Get-Date).AddDays(-y).ToUniversalTime()
- VMName
- DBName(Only for SQL DB)
Where x and y are the time-range between which you want to move the recovery points.
A list of archivable recovery point
$ArchivableRecoveryPoints = .\viewArchivableRPs.ps1 -Subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -ResourceGroupName "ResourceGroupName" -VaultName "VaultName" -ItemType "MSSQL/AzureVM" -VMName "VMName" -DBName "DBName" -StartDate (Get-Date).AddDays(-165).ToUniversalTime() -EndDate (Get-date).AddDays(0).ToUniversalTime()
Download moveArchivableRecoveryPointsForSQL
This sample script moves all the archivable recovery point for a particular SQL Backup Item to archive.
- Subscription
- ResourceGroupName
- VaultName
- VMName
- DBName
- StartDate (Get-Date).AddDays(-x).ToUniversalTime()
- EndDate (Get-date).AddDays(-y).ToUniversalTime()
Where x and y are the time-range between which you want to move the recovery points.
A list of move jobs initiated for each recovery point being moved to archive.
$MoveJobsSQL = .\moveArchivableRecoveryPointsForSQL.ps1 -Subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -ResourceGroupName "ResourceGroupName" -VaultName "VaultName" -VMName "VMName" -DBName "DBName" -StartDate (Get-Date).AddDays(-165).ToUniversalTime() -EndDate (Get-date).AddDays(0).ToUniversalTime()
Download moveArchivableRecoveryPointsForSQLServer
This sample script moves all the archivable recovery point for all the databases for a SQLServer to archive.
- Subscription
- ResourceGroupName
- VaultName
- ServerName
- StartDate (Get-Date).AddDays(-x).ToUniversalTime()
- EndDate (Get-date).AddDays(-y).ToUniversalTime()
Where x and y are the time-range between which you want to move the recovery points.
A list of move jobs initiated for each recovery point being moved to archive.
$MoveJobsSQL = .\moveArchivableRecoveryPointsForSQLServer.ps1 -Subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -ResourceGroupName "ResourceGroupName" -VaultName "VaultName" -ServerName "ServerName" -StartDate (Get-Date).AddDays(-165).ToUniversalTime() -EndDate (Get-date).AddDays(0).ToUniversalTime()
Download moveRecommendedRPsForIaasVM
Move all the recommended recovery points to archive for a particular Virtual Machine workload.
- Subscription
- ResourceGroupName
- VaultName
- VMName
A list of move jobs initiated for each recovery point being moved to archive
$MoveJobsIaasVM = .\moveRecommendedRPsForIaasVM.ps1 -Subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -ResourceGroupName "ResourceGroupName" -VaultName "VaultName" -VMName "VMName"