CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-recoveryservicesbackup

Microsoft Azure Recovery Services Backup Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

backup-policies.mddocs/

Backup Policies

Comprehensive backup policy management for Azure Recovery Services including creation, modification, deletion, and assignment of backup policies. Supports various workload types including Azure VMs, SQL databases, file shares, and on-premises workloads with flexible scheduling and retention options.

Capabilities

Policy Management Operations

Core operations for managing backup policies with full CRUD functionality and policy assignment capabilities.

class BackupPoliciesOperations:
    def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[ProtectionPolicyResource]:
        """
        List all backup policies in a Recovery Services vault.

        Parameters:
        - resource_group_name: Resource group containing the vault
        - vault_name: Recovery Services vault name
        - kwargs: Additional query parameters (filter, etc.)

        Returns:
        Iterable of ProtectionPolicyResource objects
        """

class ProtectionPoliciesOperations:
    def get(self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs) -> ProtectionPolicyResource:
        """
        Get a specific backup policy by name.

        Parameters:
        - resource_group_name: Resource group containing the vault
        - vault_name: Recovery Services vault name  
        - policy_name: Name of the backup policy
        - kwargs: Additional options

        Returns:
        ProtectionPolicyResource object
        """

    def create_or_update(
        self, 
        resource_group_name: str, 
        vault_name: str, 
        policy_name: str, 
        parameters: ProtectionPolicyResource, 
        **kwargs
    ) -> ProtectionPolicyResource:
        """
        Create or update a backup policy.

        Parameters:
        - resource_group_name: Resource group containing the vault
        - vault_name: Recovery Services vault name
        - policy_name: Name for the backup policy
        - parameters: Policy configuration details
        - kwargs: Additional options

        Returns:
        Created or updated ProtectionPolicyResource
        """

    def delete(self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs) -> None:
        """
        Delete a backup policy.

        Parameters:
        - resource_group_name: Resource group containing the vault
        - vault_name: Recovery Services vault name
        - policy_name: Name of the policy to delete
        - kwargs: Additional options
        """

Usage example:

# List all policies
policies = client.backup_policies.list("my-rg", "my-vault")
for policy in policies:
    print(f"Policy: {policy.name}, Type: {policy.properties.backup_management_type}")

# Get specific policy
vm_policy = client.protection_policies.get("my-rg", "my-vault", "DefaultPolicy")
print(f"Schedule: {vm_policy.properties.schedule_policy}")

# Create new VM policy
from azure.mgmt.recoveryservicesbackup.activestamp.models import (
    ProtectionPolicyResource,
    AzureIaaSVMProtectionPolicy,
    SimpleSchedulePolicy,
    LongTermRetentionPolicy
)

new_policy = ProtectionPolicyResource(
    properties=AzureIaaSVMProtectionPolicy(
        backup_management_type="AzureIaasVM",
        schedule_policy=SimpleSchedulePolicy(
            schedule_run_frequency="Daily",
            schedule_run_times=["22:00"]
        ),
        retention_policy=LongTermRetentionPolicy(
            daily_schedule={
                "retention_times": ["22:00"],
                "retention_duration": {
                    "count": 30,
                    "duration_type": "Days"
                }
            }
        )
    )
)

created_policy = client.protection_policies.create_or_update(
    "my-rg", "my-vault", "MyCustomPolicy", new_policy
)

Protection Policy Operations

Advanced policy operations including operation result tracking and status monitoring.

class ProtectionPoliciesOperations:
    def list(self, resource_group_name: str, vault_name: str, **kwargs) -> Iterable[ProtectionPolicyResource]:
        """List protection policies with advanced filtering options."""

    def get(self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs) -> ProtectionPolicyResource:
        """Get protection policy with detailed information."""

    def create_or_update(
        self, 
        resource_group_name: str, 
        vault_name: str, 
        policy_name: str, 
        parameters: ProtectionPolicyResource, 
        **kwargs
    ) -> ProtectionPolicyResource:
        """Create or update protection policy with validation."""

    def delete(self, resource_group_name: str, vault_name: str, policy_name: str, **kwargs) -> None:
        """Delete protection policy with dependency checks."""

class ProtectionPolicyOperationResultsOperations:
    def get(self, resource_group_name: str, vault_name: str, policy_name: str, operation_id: str, **kwargs) -> ProtectionPolicyResource:
        """Get operation result for policy operations."""

class ProtectionPolicyOperationStatusesOperations:
    def get(self, resource_group_name: str, vault_name: str, policy_name: str, operation_id: str, **kwargs) -> OperationStatus:
        """Get operation status for policy operations."""

Policy Types

Azure IaaS VM Policies

Backup policies specifically designed for Azure virtual machines with flexible scheduling and retention options.

class AzureIaaSVMProtectionPolicy:
    def __init__(
        self,
        backup_management_type: str = "AzureIaasVM",
        schedule_policy: Optional[SchedulePolicy] = None,
        retention_policy: Optional[RetentionPolicy] = None,
        instant_rp_retention_range_in_days: Optional[int] = None,
        time_zone: Optional[str] = None,
        policy_type: str = "V2",
        **kwargs
    ):
        """
        Azure IaaS VM protection policy.

        Parameters:
        - backup_management_type: Always "AzureIaasVM"
        - schedule_policy: Backup schedule configuration
        - retention_policy: Backup retention configuration
        - instant_rp_retention_range_in_days: Instant recovery point retention (1-30 days)
        - time_zone: Time zone for schedule (e.g., "UTC", "Eastern Standard Time")
        - policy_type: Policy version ("V1" or "V2")
        """

    backup_management_type: str
    schedule_policy: Optional[SchedulePolicy]
    retention_policy: Optional[RetentionPolicy] 
    instant_rp_retention_range_in_days: Optional[int]
    time_zone: Optional[str]
    policy_type: str

Azure SQL Database Policies

Specialized policies for SQL database backup with transaction log backup support.

class AzureSqlProtectionPolicy:
    def __init__(
        self,
        backup_management_type: str = "AzureSql",
        retention_policy: Optional[RetentionPolicy] = None,
        **kwargs
    ):
        """
        Azure SQL database protection policy.

        Parameters:
        - backup_management_type: Always "AzureSql"
        - retention_policy: Backup retention configuration
        """

    backup_management_type: str
    retention_policy: Optional[RetentionPolicy]

Azure File Share Policies

Policies for Azure file share backup with snapshot-based protection.

class AzureFileShareProtectionPolicy:
    def __init__(
        self,
        backup_management_type: str = "AzureStorage",
        schedule_policy: Optional[SchedulePolicy] = None,
        retention_policy: Optional[RetentionPolicy] = None,
        time_zone: Optional[str] = None,
        work_load_type: str = "AzureFileShare",
        **kwargs
    ):
        """
        Azure file share protection policy.

        Parameters:
        - backup_management_type: Always "AzureStorage"
        - schedule_policy: Backup schedule configuration
        - retention_policy: Backup retention configuration
        - time_zone: Time zone for schedule
        - work_load_type: Always "AzureFileShare"
        """

    backup_management_type: str
    schedule_policy: Optional[SchedulePolicy]
    retention_policy: Optional[RetentionPolicy]
    time_zone: Optional[str]
    work_load_type: str

Azure VM Workload Policies

Comprehensive policies for workloads running inside Azure VMs (SQL Server, SAP HANA, etc.).

class AzureVmWorkloadProtectionPolicy:
    def __init__(
        self,
        backup_management_type: str = "AzureWorkload",
        work_load_type: Optional[str] = None,
        settings: Optional[Settings] = None,
        sub_protection_policy: Optional[List[SubProtectionPolicy]] = None,
        make_policy_consistent: Optional[bool] = None,
        **kwargs
    ):
        """
        Azure VM workload protection policy.

        Parameters:
        - backup_management_type: Always "AzureWorkload"
        - work_load_type: Workload type ("SQLDataBase", "SAPHanaDatabase", etc.)
        - settings: Workload-specific settings
        - sub_protection_policy: List of sub-policies for different backup types
        - make_policy_consistent: Ensure policy consistency across workloads
        """

    backup_management_type: str
    work_load_type: Optional[str]
    settings: Optional[Settings]
    sub_protection_policy: Optional[List[SubProtectionPolicy]]
    make_policy_consistent: Optional[bool]

Schedule Policies

Simple Schedule Policy

Basic scheduling for daily, weekly backup operations.

class SimpleSchedulePolicy:
    def __init__(
        self,
        schedule_run_frequency: str,
        schedule_run_times: Optional[List[str]] = None,
        schedule_run_days: Optional[List[str]] = None,
        schedule_weekly_frequency: Optional[int] = None,
        **kwargs
    ):
        """
        Simple backup schedule policy.

        Parameters:
        - schedule_run_frequency: "Daily", "Weekly"
        - schedule_run_times: List of times in HH:MM format (e.g., ["22:00"])
        - schedule_run_days: Days for weekly schedule (e.g., ["Sunday", "Wednesday"])
        - schedule_weekly_frequency: Week interval for weekly schedules
        """

    schedule_run_frequency: str
    schedule_run_times: Optional[List[str]]
    schedule_run_days: Optional[List[str]]
    schedule_weekly_frequency: Optional[int]

Log Schedule Policy

Specialized scheduling for transaction log backups in workload scenarios.

class LogSchedulePolicy:
    def __init__(
        self,
        schedule_frequency_in_mins: Optional[int] = None,
        **kwargs
    ):
        """
        Log backup schedule policy.

        Parameters:
        - schedule_frequency_in_mins: Frequency in minutes (15, 30, 60, 120, 240, 480, 720, 1440)
        """

    schedule_frequency_in_mins: Optional[int]

Retention Policies

Long Term Retention Policy

Comprehensive retention policy supporting daily, weekly, monthly, and yearly retention cycles.

class LongTermRetentionPolicy:
    def __init__(
        self,
        daily_schedule: Optional[DailyRetentionSchedule] = None,
        weekly_schedule: Optional[WeeklyRetentionSchedule] = None,
        monthly_schedule: Optional[MonthlyRetentionSchedule] = None,
        yearly_schedule: Optional[YearlyRetentionSchedule] = None,
        **kwargs
    ):
        """
        Long-term retention policy configuration.

        Parameters:
        - daily_schedule: Daily retention settings
        - weekly_schedule: Weekly retention settings  
        - monthly_schedule: Monthly retention settings
        - yearly_schedule: Yearly retention settings
        """

    daily_schedule: Optional[DailyRetentionSchedule]
    weekly_schedule: Optional[WeeklyRetentionSchedule] 
    monthly_schedule: Optional[MonthlyRetentionSchedule]
    yearly_schedule: Optional[YearlyRetentionSchedule]

class DailyRetentionSchedule:
    retention_times: Optional[List[str]]
    retention_duration: Optional[RetentionDuration]

class WeeklyRetentionSchedule:
    days_of_the_week: Optional[List[str]]
    retention_times: Optional[List[str]]
    retention_duration: Optional[RetentionDuration]

class MonthlyRetentionSchedule:
    retention_schedule_format_type: Optional[str]  # "Daily" or "Weekly"
    retention_schedule_daily: Optional[DailyRetentionFormat]
    retention_schedule_weekly: Optional[WeeklyRetentionFormat]
    retention_times: Optional[List[str]]  
    retention_duration: Optional[RetentionDuration]

class YearlyRetentionSchedule:
    retention_schedule_format_type: Optional[str]  # "Daily" or "Weekly"
    months_of_year: Optional[List[str]]
    retention_schedule_daily: Optional[DailyRetentionFormat]
    retention_schedule_weekly: Optional[WeeklyRetentionFormat]
    retention_times: Optional[List[str]]
    retention_duration: Optional[RetentionDuration]

class RetentionDuration:
    count: Optional[int]
    duration_type: Optional[str]  # "Days", "Weeks", "Months", "Years"

Simple Retention Policy

Basic retention policy for straightforward backup retention requirements.

class SimpleRetentionPolicy:
    def __init__(
        self,
        retention_duration: Optional[RetentionDuration] = None,
        **kwargs
    ):
        """Simple retention policy with single duration."""

    retention_duration: Optional[RetentionDuration]

Usage Examples

Create VM Backup Policy

from azure.mgmt.recoveryservicesbackup.activestamp.models import (
    ProtectionPolicyResource,
    AzureIaaSVMProtectionPolicy,
    SimpleSchedulePolicy,
    LongTermRetentionPolicy,
    DailyRetentionSchedule,
    WeeklyRetentionSchedule,
    RetentionDuration
)

# Define retention schedules
daily_retention = DailyRetentionSchedule(
    retention_times=["02:00"],
    retention_duration=RetentionDuration(count=30, duration_type="Days")
)

weekly_retention = WeeklyRetentionSchedule(
    days_of_the_week=["Sunday"],
    retention_times=["02:00"],
    retention_duration=RetentionDuration(count=12, duration_type="Weeks")
)

# Create VM policy
vm_policy = ProtectionPolicyResource(
    properties=AzureIaaSVMProtectionPolicy(
        backup_management_type="AzureIaasVM",
        schedule_policy=SimpleSchedulePolicy(
            schedule_run_frequency="Daily",
            schedule_run_times=["02:00"]
        ),
        retention_policy=LongTermRetentionPolicy(
            daily_schedule=daily_retention,
            weekly_schedule=weekly_retention
        ),
        instant_rp_retention_range_in_days=2,
        time_zone="UTC"
    )
)

# Create the policy
result = client.protection_policies.create_or_update(
    "my-rg", "my-vault", "VMDailyPolicy", vm_policy
)

Create SQL Database Policy

from azure.mgmt.recoveryservicesbackup.activestamp.models import (
    AzureVmWorkloadProtectionPolicy,
    SubProtectionPolicy,
    LogSchedulePolicy,
    SimpleRetentionPolicy
)

# SQL database workload policy
sql_policy = ProtectionPolicyResource(
    properties=AzureVmWorkloadProtectionPolicy(
        backup_management_type="AzureWorkload",
        work_load_type="SQLDataBase",
        sub_protection_policy=[
            SubProtectionPolicy(
                policy_type="Full",
                schedule_policy=SimpleSchedulePolicy(
                    schedule_run_frequency="Weekly",
                    schedule_run_times=["02:00"],
                    schedule_run_days=["Sunday"]
                ),
                retention_policy=LongTermRetentionPolicy(
                    weekly_schedule=WeeklyRetentionSchedule(
                        days_of_the_week=["Sunday"],
                        retention_times=["02:00"],
                        retention_duration=RetentionDuration(count=52, duration_type="Weeks")
                    )
                )
            ),
            SubProtectionPolicy(
                policy_type="Log",
                schedule_policy=LogSchedulePolicy(
                    schedule_frequency_in_mins=15
                ),
                retention_policy=SimpleRetentionPolicy(
                    retention_duration=RetentionDuration(count=7, duration_type="Days")
                )
            )
        ]
    )
)

result = client.protection_policies.create_or_update(
    "my-rg", "my-vault", "SQLDatabasePolicy", sql_policy
)

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-recoveryservicesbackup

docs

backup-operations.md

backup-policies.md

client-management.md

cross-region-restore.md

index.md

job-management.md

protected-items.md

restore-operations.md

vault-configuration.md

tile.json