Upravit

Sdílet prostřednictvím


Get-AzRecoveryServicesBackupJob

Gets Backup jobs.

Syntax

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.

Type:Nullable<T>[BackupManagementType]
Accepted values:AzureVM, AzureStorage, AzureWorkload, MAB
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
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:Nullable<T>[DateTime]
Position:3
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Job

Specifies the job to get.

Type:JobBase
Position:6
Default value:None
Required:False
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 a Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.JobBase object.

Type:String
Position:5
Default value:None
Required:False
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
  • BackupDataMove
Type:Nullable<T>[JobOperation]
Accepted values:Backup, Restore, ConfigureBackup, DisableBackup, DeleteBackupData, BackupDataMove, UpdateCustomerManagedKey
Position:2
Default value:None
Required:False
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:Nullable<T>[JobStatus]
Accepted values:InProgress, Cancelling, Cancelled, Completed, CompletedWithWarnings, Failed
Position:1
Default value:None
Required:False
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:Nullable<T>[DateTime]
Position:4
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UseSecondaryRegion

Filters from Secondary Region for Cross Region Restore

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VaultId

ARM ID of the Recovery Services Vault.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-VaultLocation

Location of the Recovery Services Vault used to fetch the secondary region jobs.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Outputs

JobBase