Get-AzRecoveryServicesBackupJob
Syntax
Default (Default)
Get-AzRecoveryServicesBackupJob
[[-Status] <JobStatus>]
[[-Operation] <JobOperation>]
[[-From] <DateTime>]
[[-To] <DateTime>]
[[-JobId] <String>]
[[-Job] <JobBase>]
[-BackupManagementType <BackupManagementType>]
[-UseSecondaryRegion]
[-VaultLocation <String>]
[-VaultId <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Get-AzRecoveryServicesBackupJob cmdlet gets Azure Backup jobs for a specific vault.
Set the vault context by using the -VaultId parameter.
Examples
Example 1: Get all in-progress jobs
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
$Joblist = Get-AzRecoveryServicesBackupJob -Status InProgress -VaultId $vault.ID
$Joblist[0]
WorkloadName Operation Status StartTime EndTime
------------ --------- ------ --------- -------
V2VM Backup InProgress 4/23/2016 5:00:30 PM 1/1/2001 12:00:00
The first command gets status of an in-progress jobs as an array, and then stores it in the $Joblist variable.
The second command displays the first item in the $Joblist array.
Example 2: Get all failed jobs in the last 7 days
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
Get-AzRecoveryServicesBackupJob -From (Get-Date).AddDays(-7).ToUniversalTime() -Status Failed -VaultId $vault.ID
This command gets failed jobs from the last week in the vault.
The From parameter specifies a time seven days in the past specified in UTC.
The command does not specify a value for the To parameter.
Therefore, it uses the default value of the current time.
Example 3: Get an in-progress job and wait for completion
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
$Jobs = Get-AzRecoveryServicesBackupJob -Status InProgress -VaultId $vault.ID
$Job = $Jobs[0]
While ( $Job.Status -ne "Completed" ) {
Write-Host -Object "Waiting for completion..."
Start-Sleep -Seconds 10
$Job = Get-AzRecoveryServicesBackupJob -Job $Job -VaultId $vault.ID
}
Write-Host -Object "Done!"
Waiting for completion...
Waiting for completion...
Waiting for completion...
Done!
This script polls the first job that is currently in progress until the job has completed.
Note: You can use Wait-AzRecoveryServicesBackupJob cmdlet to wait for an Azure Backup job to finish instead of While loop.
Example 4: Get all AzureVM jobs in last 2 days which finished successfully
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
$Jobs = Get-AzRecoveryServicesBackupJob -VaultId $vault.ID -Status Completed -From (Get-Date).AddDays(-2).ToUniversalTime() -BackupManagementType AzureVM
First cmdlet fetches the vault object. Second cmdlet stores all the AzureVM jobs in the given vault which completed in last 2 days to $jobs. Change the value of BackupManagementType parameter to MAB in order to fetch MAB agent jobs.
Example 5: Get jobs for cross region restore
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
$Jobs = Get-AzRecoveryServicesBackupJob -VaultId $vault.Id -From ((Get-Date).AddDays(-29)).ToUniversalTime() -Operation CrossRegionRestore
First cmdlet fetches the vault object. Second cmdlet fetches all Cross region restore jobs in last 29 days for a given recovery services vault.
Parameters
-BackupManagementType
The class of resources being protected. Currently the values supported for this cmdlet are AzureVM, AzureStorage, AzureWorkload, MAB.
Parameter properties
Type: Nullable<T> [ BackupManagementType ]
Default value: None
Accepted values: AzureVM, AzureStorage, AzureWorkload, MAB
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-From
Specifies the start, as a DateTime object, of a time range for the jobs that this cmdlet gets.
To obtain a DateTime object, use the Get-Date cmdlet.
For more information about DateTime objects, type Get-Help Get-Date
.
Use UTC format for dates.
Parameter properties
Parameter sets
(All)
Position: 3
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Job
Specifies the job to get.
Parameter properties
Type: JobBase
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 6
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-JobId
Specifies the ID of a job that this cmdlet gets.
The ID is the JobId property of a Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobBase object.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 5
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Operation
Specifies an operation of the jobs that this cmdlet gets.
The acceptable values for this parameter are:
Backup
ConfigureBackup
DeleteBackupData
DisableBackup
Restore
BackupDataMove
Parameter properties
Type: Nullable<T> [ JobOperation ]
Default value: None
Accepted values: Backup, Restore, ConfigureBackup, DisableBackup, DeleteBackupData, BackupDataMove, UpdateCustomerManagedKey
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 2
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Status
Specifies a status of the jobs that this cmdlet gets.
The acceptable values for this parameter are:
InProgress
Failed
Cancelled
Cancelling
Completed
CompletedWithWarnings
Parameter properties
Type: Nullable<T> [ JobStatus ]
Default value: None
Accepted values: InProgress, Cancelling, Cancelled, Completed, CompletedWithWarnings, Failed
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 1
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-To
Specifies the end, as a DateTime object, of a time range for the jobs that this cmdlet gets.
The default value is the current system time.
If you specify this parameter, you must also specify the -From parameter.
Use UTC format for dates.
Parameter properties
Parameter sets
(All)
Position: 4
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-UseSecondaryRegion
Filters from Secondary Region for Cross Region Restore
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-VaultId
ARM ID of the Recovery Services Vault.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-VaultLocation
Location of the Recovery Services Vault used to fetch the secondary region jobs.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs