or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

backup-operations.mdbackup-policies.mdclient-management.mdcross-region-restore.mdindex.mdjob-management.mdprotected-items.mdrestore-operations.mdvault-configuration.md

job-management.mddocs/

0

# Job Management

1

2

Comprehensive backup and restore job lifecycle management including job monitoring, cancellation, result retrieval, and detailed status tracking across all supported workload types. Provides complete operational visibility and control over backup operations with extensive filtering and export capabilities.

3

4

## Capabilities

5

6

### Job Operations

7

8

Core operations for managing backup and restore jobs with comprehensive tracking and control.

9

10

```python { .api }

11

class BackupJobsOperations:

12

def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[JobResource]:

13

"""

14

List jobs in a Recovery Services vault.

15

16

Parameters:

17

- resource_group_name: Resource group containing the vault

18

- vault_name: Recovery Services vault name

19

- kwargs: Filter options (status, operation, start_time, end_time, backup_management_type, etc.)

20

21

Returns:

22

Iterable of JobResource objects

23

"""

24

25

class JobDetailsOperations:

26

def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> JobResource:

27

"""

28

Get details of a specific job.

29

30

Parameters:

31

- resource_group_name: Resource group containing the vault

32

- vault_name: Recovery Services vault name

33

- job_name: Name/ID of the job

34

- kwargs: Additional options

35

36

Returns:

37

JobResource with detailed job information

38

"""

39

40

class JobCancellationsOperations:

41

def trigger(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> None:

42

"""

43

Cancel a running job.

44

45

Parameters:

46

- resource_group_name: Resource group containing the vault

47

- vault_name: Recovery Services vault name

48

- job_name: Name/ID of the job to cancel

49

- kwargs: Additional options

50

"""

51

52

class JobsOperations:

53

def export(self, resource_group_name: str, vault_name: str, **kwargs) -> None:

54

"""

55

Export jobs to a storage account for analysis.

56

57

Parameters:

58

- resource_group_name: Resource group containing the vault

59

- vault_name: Recovery Services vault name

60

- kwargs: Export parameters (storage account, filters, date range, etc.)

61

"""

62

```

63

64

Usage example:

65

66

```python

67

from datetime import datetime, timedelta

68

69

# List recent backup jobs

70

end_time = datetime.utcnow()

71

start_time = end_time - timedelta(days=7)

72

73

jobs = client.backup_jobs.list(

74

"my-rg", "my-vault",

75

filter=f"startTime eq '{start_time.isoformat()}' and endTime eq '{end_time.isoformat()}' and operation eq 'Backup'"

76

)

77

78

for job in jobs:

79

print(f"Job: {job.name}")

80

print(f"Operation: {job.properties.operation}")

81

print(f"Status: {job.properties.status}")

82

print(f"Entity: {job.properties.entity_friendly_name}")

83

print(f"Duration: {job.properties.duration}")

84

print("---")

85

86

# Get specific job details

87

job_details = client.job_details.get("my-rg", "my-vault", "job-id-12345")

88

print(f"Job Status: {job_details.properties.status}")

89

print(f"Start Time: {job_details.properties.start_time}")

90

print(f"End Time: {job_details.properties.end_time}")

91

92

if job_details.properties.error_details:

93

for error in job_details.properties.error_details:

94

print(f"Error: {error.error_code} - {error.error_string}")

95

```

96

97

### Specialized Job Operations

98

99

Extended job operations with detailed information and operation result tracking.

100

101

```python { .api }

102

class JobDetailsOperations:

103

def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> JobResource:

104

"""

105

Get comprehensive job details including progress and sub-tasks.

106

107

Parameters:

108

- resource_group_name: Resource group containing the vault

109

- vault_name: Recovery Services vault name

110

- job_name: Name/ID of the job

111

- kwargs: Additional options

112

113

Returns:

114

JobResource with comprehensive job details

115

"""

116

117

class JobOperationResultsOperations:

118

def get(

119

self,

120

resource_group_name: str,

121

vault_name: str,

122

job_name: str,

123

operation_id: str,

124

**kwargs

125

) -> None:

126

"""

127

Get result of a job operation.

128

129

Parameters:

130

- resource_group_name: Resource group containing the vault

131

- vault_name: Recovery Services vault name

132

- job_name: Name/ID of the job

133

- operation_id: ID of the operation

134

- kwargs: Additional options

135

"""

136

137

class JobCancellationsOperations:

138

def trigger(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> None:

139

"""

140

Trigger job cancellation with tracking.

141

142

Parameters:

143

- resource_group_name: Resource group containing the vault

144

- vault_name: Recovery Services vault name

145

- job_name: Name/ID of the job to cancel

146

- kwargs: Additional options

147

"""

148

149

class ExportJobsOperationResultsOperations:

150

def get(

151

self,

152

resource_group_name: str,

153

vault_name: str,

154

operation_id: str,

155

**kwargs

156

) -> OperationResultInfoBaseResource:

157

"""

158

Get result of job export operation.

159

160

Parameters:

161

- resource_group_name: Resource group containing the vault

162

- vault_name: Recovery Services vault name

163

- operation_id: ID of the export operation

164

- kwargs: Additional options

165

166

Returns:

167

OperationResultInfoBaseResource with export results

168

"""

169

```

170

171

Usage example:

172

173

```python

174

# Get detailed job information with progress

175

job_details = client.job_details.get("my-rg", "my-vault", "job-id-12345")

176

177

if hasattr(job_details.properties, 'extended_info'):

178

extended_info = job_details.properties.extended_info

179

if hasattr(extended_info, 'progress_percentage'):

180

print(f"Progress: {extended_info.progress_percentage}%")

181

if hasattr(extended_info, 'task_list'):

182

for task in extended_info.task_list:

183

print(f"Task: {task.task_id} - {task.status}")

184

185

# Cancel a running job

186

client.job_cancellations.trigger("my-rg", "my-vault", "job-id-12345")

187

print("Job cancellation triggered")

188

```

189

190

### Backup Job Operations

191

192

Specialized operations for backup-specific jobs with enhanced filtering and management.

193

194

```python { .api }

195

class BackupJobsOperations:

196

def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[JobResource]:

197

"""

198

List backup jobs with backup-specific filtering.

199

200

Parameters:

201

- resource_group_name: Resource group containing the vault

202

- vault_name: Recovery Services vault name

203

- kwargs: Backup-specific filter options

204

205

Returns:

206

Iterable of JobResource objects for backup operations

207

"""

208

209

def get(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> JobResource:

210

"""Get backup job with backup-specific details."""

211

212

def cancel(self, resource_group_name: str, vault_name: str, job_name: str, **kwargs) -> None:

213

"""Cancel backup job with backup-specific validation."""

214

```

215

216

## Job Filtering and Querying

217

218

### Advanced Job Filtering

219

220

The job list operations support comprehensive filtering using OData query syntax.

221

222

```python { .api }

223

# Filter parameters for job queries

224

class JobFilters:

225

# Status filters

226

status: str # "InProgress", "Completed", "Failed", "CompletedWithWarnings", "Cancelled", "Cancelling"

227

228

# Operation filters

229

operation: str # "Backup", "Restore", "ConfigureBackup", "DisableBackup", "DeleteBackupData"

230

231

# Time range filters

232

start_time: datetime # Start time for job query

233

end_time: datetime # End time for job query

234

235

# Workload filters

236

backup_management_type: str # "AzureIaasVM", "AzureStorage", "AzureWorkload", "DPM", "MABS"

237

workload_type: str # "VM", "FileShare", "SQLDataBase", "SAPHanaDatabase"

238

239

# Entity filters

240

backup_item_name: str # Name of the backed up item

241

backup_item_type: str # Type of the backed up item

242

243

# Additional filters

244

policy_name: str # Name of the backup policy

245

vault_name: str # Name of the vault (for cross-vault queries)

246

```

247

248

Usage examples:

249

250

```python

251

from datetime import datetime, timedelta

252

253

# Get failed jobs from last 24 hours

254

failed_jobs = client.backup_jobs.list(

255

"my-rg", "my-vault",

256

filter="status eq 'Failed' and startTime ge datetime'2024-01-15T00:00:00Z'"

257

)

258

259

# Get all VM backup jobs

260

vm_jobs = client.backup_jobs.list(

261

"my-rg", "my-vault",

262

filter="operation eq 'Backup' and backupManagementType eq 'AzureIaasVM'"

263

)

264

265

# Get jobs for specific protected item

266

item_jobs = client.backup_jobs.list(

267

"my-rg", "my-vault",

268

filter="backupItemName eq 'vm;iaasvmcontainerv2;vm-rg;my-vm'"

269

)

270

271

# Get restore jobs in progress

272

restore_jobs = client.backup_jobs.list(

273

"my-rg", "my-vault",

274

filter="operation eq 'Restore' and status eq 'InProgress'"

275

)

276

```

277

278

## Job Types and Extended Information

279

280

### Extended Job Information

281

282

Different job types provide specific extended information for detailed monitoring.

283

284

```python { .api }

285

class AzureIasSVMJobExtendedInfo:

286

def __init__(

287

self,

288

task_list: Optional[List[AzureIaaSVMJobTaskDetails]] = None,

289

property_bag: Optional[Dict[str, str]] = None,

290

internal_property_bag: Optional[Dict[str, str]] = None,

291

progress_percentage: Optional[float] = None,

292

estimated_remaining_duration: Optional[str] = None,

293

dynamic_error_message: Optional[str] = None,

294

**kwargs

295

):

296

"""

297

Extended information for Azure IaaS VM jobs.

298

299

Parameters:

300

- task_list: List of job tasks and their status

301

- property_bag: Additional job properties

302

- internal_property_bag: Internal properties

303

- progress_percentage: Job completion percentage

304

- estimated_remaining_duration: Estimated time to completion

305

- dynamic_error_message: Dynamic error information

306

"""

307

308

task_list: Optional[List[AzureIaaSVMJobTaskDetails]]

309

property_bag: Optional[Dict[str, str]]

310

internal_property_bag: Optional[Dict[str, str]]

311

progress_percentage: Optional[float]

312

estimated_remaining_duration: Optional[str]

313

dynamic_error_message: Optional[str]

314

315

class AzureIaaSVMJobTaskDetails:

316

def __init__(

317

self,

318

task_id: Optional[str] = None,

319

start_time: Optional[datetime] = None,

320

end_time: Optional[datetime] = None,

321

instance_id: Optional[str] = None,

322

duration: Optional[str] = None,

323

status: Optional[str] = None,

324

progress_percentage: Optional[float] = None,

325

task_execution_details: Optional[str] = None,

326

**kwargs

327

):

328

"""

329

Task details for Azure IaaS VM jobs.

330

331

Parameters:

332

- task_id: Unique task identifier

333

- start_time: Task start time

334

- end_time: Task end time (if completed)

335

- instance_id: Instance identifier

336

- duration: Task execution duration

337

- status: Task status

338

- progress_percentage: Task completion percentage

339

- task_execution_details: Detailed task execution information

340

"""

341

342

task_id: Optional[str]

343

start_time: Optional[datetime]

344

end_time: Optional[datetime]

345

instance_id: Optional[str]

346

duration: Optional[str]

347

status: Optional[str]

348

progress_percentage: Optional[float]

349

task_execution_details: Optional[str]

350

```

351

352

### Job Error Information

353

354

Comprehensive error information for failed jobs across different workload types.

355

356

```python { .api }

357

class AzureIaaSVMErrorInfo:

358

def __init__(

359

self,

360

error_code: Optional[int] = None,

361

error_string: Optional[str] = None,

362

error_title: Optional[str] = None,

363

recommendations: Optional[List[str]] = None,

364

**kwargs

365

):

366

"""

367

Error information for Azure IaaS VM jobs.

368

369

Parameters:

370

- error_code: Numeric error code

371

- error_string: Error description

372

- error_title: Error title/summary

373

- recommendations: List of recommended actions

374

"""

375

376

error_code: Optional[int]

377

error_string: Optional[str]

378

error_title: Optional[str]

379

recommendations: Optional[List[str]]

380

381

class AzureStorageErrorInfo:

382

def __init__(

383

self,

384

error_code: Optional[int] = None,

385

error_string: Optional[str] = None,

386

**kwargs

387

):

388

"""Error information for Azure Storage jobs."""

389

390

error_code: Optional[int]

391

error_string: Optional[str]

392

393

class AzureWorkloadErrorInfo:

394

def __init__(

395

self,

396

error_code: Optional[int] = None,

397

error_string: Optional[str] = None,

398

additional_details: Optional[str] = None,

399

**kwargs

400

):

401

"""Error information for Azure Workload jobs."""

402

403

error_code: Optional[int]

404

error_string: Optional[str]

405

additional_details: Optional[str]

406

```

407

408

## Usage Examples

409

410

### Monitor Job Progress

411

412

```python

413

import time

414

415

def monitor_job_progress(resource_group_name, vault_name, job_name):

416

"""Monitor job progress until completion."""

417

418

while True:

419

job = client.job_details.get(resource_group_name, vault_name, job_name)

420

status = job.properties.status

421

422

print(f"Job Status: {status}")

423

424

# Check for extended info with progress

425

if hasattr(job.properties, 'extended_info') and job.properties.extended_info:

426

ext_info = job.properties.extended_info

427

if hasattr(ext_info, 'progress_percentage') and ext_info.progress_percentage:

428

print(f"Progress: {ext_info.progress_percentage}%")

429

430

if hasattr(ext_info, 'estimated_remaining_duration') and ext_info.estimated_remaining_duration:

431

print(f"Estimated remaining: {ext_info.estimated_remaining_duration}")

432

433

# Show task details

434

if hasattr(ext_info, 'task_list') and ext_info.task_list:

435

for task in ext_info.task_list:

436

print(f" Task {task.task_id}: {task.status}")

437

if task.progress_percentage:

438

print(f" Progress: {task.progress_percentage}%")

439

440

# Check if job is complete

441

if status in ["Completed", "Failed", "CompletedWithWarnings", "Cancelled"]:

442

print(f"Job finished with status: {status}")

443

444

# Show error details if failed

445

if status == "Failed" and job.properties.error_details:

446

for error in job.properties.error_details:

447

print(f"Error: {error.error_code} - {error.error_string}")

448

if hasattr(error, 'recommendations') and error.recommendations:

449

print("Recommendations:")

450

for rec in error.recommendations:

451

print(f" - {rec}")

452

break

453

454

time.sleep(30) # Wait 30 seconds before checking again

455

456

# Monitor a specific job

457

monitor_job_progress("my-rg", "my-vault", "backup-job-id-12345")

458

```

459

460

### Export Job History

461

462

```python

463

from azure.mgmt.recoveryservicesbackup.activestamp.models import ExportJobsRequest

464

465

# Export job history for the last 30 days

466

export_request = ExportJobsRequest(

467

start_time=datetime.utcnow() - timedelta(days=30),

468

end_time=datetime.utcnow(),

469

job_operation_type="All", # "Backup", "Restore", "All"

470

job_status_type="All", # "InProgress", "Completed", "Failed", "All"

471

job_backup_management_type="All" # "AzureIaasVM", "AzureStorage", "All"

472

)

473

474

# Trigger export operation

475

client.jobs.export(

476

resource_group_name="my-rg",

477

vault_name="my-vault",

478

parameters=export_request

479

)

480

481

print("Job export initiated - check export operation results")

482

```

483

484

### Handle Failed Jobs

485

486

```python

487

# Get all failed jobs from the last week

488

failed_jobs = client.backup_jobs.list(

489

"my-rg", "my-vault",

490

filter=f"status eq 'Failed' and startTime ge datetime'{(datetime.utcnow() - timedelta(days=7)).isoformat()}Z'"

491

)

492

493

print("=== Failed Jobs Analysis ===")

494

error_summary = {}

495

496

for job in failed_jobs:

497

print(f"\nJob: {job.name}")

498

print(f"Operation: {job.properties.operation}")

499

print(f"Entity: {job.properties.entity_friendly_name}")

500

print(f"Start Time: {job.properties.start_time}")

501

502

if job.properties.error_details:

503

for error in job.properties.error_details:

504

error_code = error.error_code

505

error_summary[error_code] = error_summary.get(error_code, 0) + 1

506

507

print(f"Error: {error_code} - {error.error_string}")

508

509

# Show recommendations if available

510

if hasattr(error, 'recommendations') and error.recommendations:

511

print("Recommendations:")

512

for rec in error.recommendations:

513

print(f" - {rec}")

514

515

print(f"\n=== Error Summary ===")

516

for error_code, count in error_summary.items():

517

print(f"Error {error_code}: {count} occurrences")

518

```

519

520

### Cancel Running Jobs

521

522

```python

523

# Get all running jobs

524

running_jobs = client.backup_jobs.list(

525

"my-rg", "my-vault",

526

filter="status eq 'InProgress'"

527

)

528

529

print("Running jobs:")

530

for job in running_jobs:

531

print(f"- {job.name}: {job.properties.operation} on {job.properties.entity_friendly_name}")

532

533

# Cancel if it's a restore job that's been running too long

534

if (job.properties.operation == "Restore" and

535

job.properties.start_time < datetime.utcnow() - timedelta(hours=4)):

536

537

print(f" Cancelling long-running restore job: {job.name}")

538

client.job_cancellations.trigger("my-rg", "my-vault", job.name)

539

```