Get-AzRecoveryServicesBackupJob

Gets Backup jobs.

Syntax

Get-AzRecoveryServicesBackupJob
   [[-Status] <JobStatus>]
   [[-Operation] <JobOperation>]
   [[-From] <DateTime>]
   [[-To] <DateTime>]
   [[-JobId] <String>]
   [[-Job] <JobBase>]
   [-BackupManagementType <BackupManagementType>]
   [-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

PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
PS C:\> $Joblist = Get-AzRecoveryServicesBackupJob -Status InProgress -VaultId $vault.ID
PS C:\> $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

PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
PS C:\> 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.

Parameters

-BackupManagementType

Specifies the Backup management type. Currently, only AzureVM, AzureStorage is supported.

Type:System.Nullable`1[Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.BackupManagementType]
Accepted values:AzureVM, MARS, SCDPM, AzureBackupServer, AzureSQL, AzureStorage, AzureWorkload
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters: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.

Type:System.Nullable`1[System.DateTime]
Position:3
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Job

Specifies the job to get.

Type:Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobBase
Position:6
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-JobId

Specifies the ID of a job that this cmdlet gets. The ID is the JobId property of an Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobBase object.

Type:String
Position:5
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Operation

Specifies an operation of the jobs that this cmdlet gets. The acceptable values for this parameter are:

  • Backup
  • ConfigureBackup
  • DeleteBackupData
  • DisableBackup
  • Restore
Type:System.Nullable`1[Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobOperation]
Accepted values:Backup, Restore, ConfigureBackup, DisableBackup, DeleteBackupData
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters: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
Type:System.Nullable`1[Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobStatus]
Accepted values:InProgress, Cancelling, Cancelled, Completed, CompletedWithWarnings, Failed
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters: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.

Type:System.Nullable`1[System.DateTime]
Position:4
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VaultId

ARM ID of the Recovery Services Vault.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Inputs

String

Outputs

Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobBase