Yandex Cloud
Поиск
Связаться с намиПодключиться
  • Истории успеха
  • Документация
  • Блог
  • Все сервисы
  • Статус работы сервисов
    • Доступны в регионе
    • Инфраструктура и сеть
    • Платформа данных
    • Контейнеры
    • Инструменты разработчика
    • Бессерверные вычисления
    • Безопасность
    • Мониторинг и управление ресурсами
    • ИИ для бизнеса
    • Бизнес-инструменты
  • Все решения
    • По отраслям
    • По типу задач
    • Экономика платформы
    • Безопасность
    • Техническая поддержка
    • Каталог партнёров
    • Обучение и сертификация
    • Облако для стартапов
    • Облако для крупного бизнеса
    • Центр технологий для общества
    • Партнёрская программа
    • Поддержка IT-бизнеса
    • Облако для фрилансеров
    • Обучение и сертификация
    • Блог
    • Документация
    • Мероприятия и вебинары
    • Контакты, чаты и сообщества
    • Идеи
    • Тарифы Yandex Cloud
    • Промоакции и free tier
    • Правила тарификации
  • Истории успеха
  • Документация
  • Блог
Проект Яндекса
© 2025 ТОО «Облачные Сервисы Казахстан»
Terraform в Yandex Cloud
  • Начало работы
  • Библиотека решений
    • Обзор
    • История изменений (англ.)
          • backup_policy
          • backup_policy_bindings

В этой статье:

  • Defined types
  • interval_type
  • day_type
  • backup_set_type
  • Example usage
  • Schema
  • Required
  • Optional
  • Read-Only
  • Nested Schema for reattempts
  • Nested Schema for retention
  • Nested Schema for retention.rules
  • Nested Schema for scheduling
  • Nested Schema for scheduling.backup_sets
  • Nested Schema for scheduling.backup_sets.execute_by_time
  • Nested Schema for scheduling.execute_by_time
  • Nested Schema for vm_snapshot_reattempts
  • Nested Schema for file_filters
  • Nested Schema for timeouts
  • Import
  1. Справочник Terraform
  2. Ресурсы (англ.)
  3. Cloud Backup
  4. Resources
  5. backup_policy

yandex_backup_policy (Resource)

Статья создана
Yandex Cloud
Обновлена 11 сентября 2025 г.
  • Defined types
    • interval_type
    • day_type
    • backup_set_type
  • Example usage
  • Schema
    • Required
    • Optional
    • Read-Only
    • Nested Schema for reattempts
    • Nested Schema for retention
    • Nested Schema for retention.rules
    • Nested Schema for scheduling
    • Nested Schema for scheduling.backup_sets
    • Nested Schema for scheduling.backup_sets.execute_by_time
    • Nested Schema for scheduling.execute_by_time
    • Nested Schema for vm_snapshot_reattempts
    • Nested Schema for file_filters
    • Nested Schema for timeouts
  • Import

Allows management of Yandex Cloud Backup Policy.

Важно

Cloud Backup Provider must be activated in order to manipulate with policies. Active it either by UI Console or by yc command.

Defined typesDefined types

interval_typeinterval_type

A string type, that accepts values in the format of: number + time type, where time type might be:

  • s — seconds
  • m — minutes
  • h — hours
  • d — days
  • w — weekdays
  • M — months

Example of interval value: 5m, 10d, 2M, 5w

day_typeday_type

A string type, that accepts the following values: ALWAYS_INCREMENTAL, ALWAYS_FULL, WEEKLY_FULL_DAILY_INCREMENTAL, WEEKLY_INCREMENTAL.

backup_set_typebackup_set_type

TYPE_AUTO, TYPE_FULL, TYPE_INCREMENTAL, TYPE_DIFFERENTIAL.

Example usageExample usage

//
// Create a new basic Cloud Backup Policy
//
resource "yandex_backup_policy" "basic_policy" {
  name = "basic policy"

  scheduling {
    enabled = false
    backup_sets {
      execute_by_interval = 86400
    }
  }

  retention {
    after_backup = false
  }

  reattempts {}

  vm_snapshot_reattempts {}
}
//
// Create a new full Cloud Backup Policy
//
resource "yandex_backup_policy" "my_policy" {
  archive_name                      = "[Machine Name]-[Plan ID]-[Unique ID]a"
  cbt                               = "USE_IF_ENABLED"
  compression                       = "NORMAL"
  fast_backup_enabled               = true
  format                            = "AUTO"
  multi_volume_snapshotting_enabled = true
  name                              = "example_name"
  performance_window_enabled        = true
  preserve_file_security_settings   = true
  quiesce_snapshotting_enabled      = true
  silent_mode_enabled               = true
  splitting_bytes                   = "9223372036854775807"
  vss_provider                      = "NATIVE"

  reattempts {
    enabled      = true
    interval     = "1m"
    max_attempts = 10
  }

  retention {
    after_backup = false

    rules {
      max_age       = "365d"
      repeat_period = []
    }
  }

  scheduling {
    enabled              = false
    max_parallel_backups = 0
    random_max_delay     = "30m"
    scheme               = "ALWAYS_INCREMENTAL"
    weekly_backup_day    = "MONDAY"


    backup_sets {
      execute_by_time {
        include_last_day_of_month = true
        monthdays                 = []
        months                    = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
        repeat_at                 = ["04:10"]
        repeat_every              = "30m"
        type                      = "MONTHLY"
        weekdays                  = []
      }
    }
  }

  vm_snapshot_reattempts {
    enabled      = true
    interval     = "1m"
    max_attempts = 10
  }
}

SchemaSchema

RequiredRequired

  • name (String) The resource name.
  • reattempts (Block Set, Min: 1, Max: 1) Amount of reattempts that should be performed while trying to make backup at the host. (see below for nested schema)
  • retention (Block Set, Min: 1, Max: 1) Retention policy for backups. Allows to setup backups lifecycle. (see below for nested schema)
  • scheduling (Block Set, Min: 1, Max: 1) Schedule settings for creating backups on the host. (see below for nested schema)
  • vm_snapshot_reattempts (Block Set, Min: 1, Max: 1) Amount of reattempts that should be performed while trying to make snapshot. (see below for nested schema)

OptionalOptional

  • archive_name (String) The name of generated archives. Default [Machine Name]-[Plan ID]-[Unique ID]a.
  • cbt (String) Configuration of Changed Block Tracking. Available values are: USE_IF_ENABLED, ENABLED_AND_USE, DO_NOT_USE. Default DO_NOT_USE.
  • compression (String) Archive compression level. Affects CPU. Available values: NORMAL, HIGH, MAX, OFF. Default: NORMAL.
  • fast_backup_enabled (Boolean) If true, determines whether a file has changed by the file size and timestamp. Otherwise, the entire file contents are compared to those stored in the backup.
  • file_filters (Block List, Max: 1) File filters to specify masks of files to backup or to exclude of backuping. (see below for nested schema)
  • folder_id (String) The folder identifier that resource belongs to. If it is not provided, the default provider folder-id is used.
  • format (String) Format of the backup. It's strongly recommend to leave this option empty or AUTO. Available values: AUTO, VERSION_11, VERSION_12.
  • lvm_snapshotting_enabled (Boolean) LVM will be used to create the volume snapshot. If LVM fails to create a snapshot (for example, because there is not enough free space), the software will create the snapshot itself.
  • multi_volume_snapshotting_enabled (Boolean) If true, snapshots of multiple volumes will be taken simultaneously. Default true.
  • performance_window_enabled (Boolean) Time windows for performance limitations of backup. Default false.
  • preserve_file_security_settings (Boolean, Deprecated) If true, a quiesced snapshot of the virtual machine will be taken. Default true.
  • quiesce_snapshotting_enabled (Boolean, Deprecated) If true, a quiesced snapshot of the virtual machine will be taken. Default true.
  • sector_by_sector (Boolean) A sector-by-sector backup of a disk or volume creates a backup copy of all sectors of the disk or volume, including those that do not contain data. Therefore, the size of such a backup copy will be equal to the size of the original disk or volume.
  • silent_mode_enabled (Boolean) If true, a user interaction will be avoided when possible. Default true.
  • splitting_bytes (String) Determines the size to split backups. It's better to leave this option unchanged. Default 9223372036854775807.
  • timeouts (Block, Optional) (see below for nested schema)
  • validation_enabled (Boolean) Validation is a time-consuming process, even with incremental or differential backups of small amounts of data. This is because not only the data physically contained in the backup copy is verified, but all data restored when it is selected. This option requires access to previously created backup copies.
  • vss_provider (String) Settings for the volume shadow copy service. Available values are: NATIVE, TARGET_SYSTEM_DEFINED. Default NATIVE.

Read-OnlyRead-Only

  • created_at (String) The creation timestamp of the resource.
  • enabled (Boolean) If this field is true, it means that the policy is enabled.
  • id (String) The ID of this resource.
  • updated_at (String) The update timestamp of the resource.

Nested Schema for Nested Schema for reattempts

Optional:

  • enabled (Boolean) Enable flag. Default true.
  • interval (String) Retry interval. See interval_type for available values. Default: 5m.
  • max_attempts (Number) Maximum number of attempts before throwing an error. Default 5.

Nested Schema for Nested Schema for retention

Optional:

  • after_backup (Boolean) Defines whether retention rule applies after creating backup or before.
  • rules (Block Set) A list of retention rules. (see below for nested schema)

Nested Schema for Nested Schema for retention.rules

Optional:

  • max_age (String) Deletes backups that older than max_age. Exactly one of max_count or max_age should be set.
  • max_count (Number) Deletes backups if it's count exceeds max_count. Exactly one of max_count or max_age should be set.
  • repeat_period (List of String) Possible types: REPEATE_PERIOD_UNSPECIFIED, HOURLY, DAILY, WEEKLY, MONTHLY. Specifies repeat period of the backupset.

Nested Schema for Nested Schema for scheduling

Optional:

  • backup_sets (Block Set) A list of schedules with backup sets that compose the whole scheme. (see below for nested schema)
  • enabled (Boolean) Enables or disables scheduling. Default true.
  • execute_by_interval (Number, Deprecated) Perform backup by interval, since last backup of the host. Maximum value is: 9999 days. See interval_type for available values. Exactly on of options should be set: execute_by_interval or execute_by_time.
  • execute_by_time (Block Set, Deprecated) Perform backup periodically at specific time. Exactly on of options should be set: execute_by_interval or execute_by_time. (see below for nested schema)
  • max_parallel_backups (Number) Maximum number of backup processes allowed to run in parallel. 0 for unlimited. Default 0.
  • random_max_delay (String) Configuration of the random delay between the execution of parallel tasks. See interval_type for available values. Default 30m.
  • scheme (String) Scheme of the backups. Available values are: ALWAYS_INCREMENTAL, ALWAYS_FULL, WEEKLY_FULL_DAILY_INCREMENTAL, WEEKLY_INCREMENTAL. Default ALWAYS_INCREMENTAL.
  • weekly_backup_day (String) A day of week to start weekly backups. See day_type for available values. Default MONDAY.

Nested Schema for Nested Schema for scheduling.backup_sets

Optional:

  • execute_by_interval (Number) Perform backup by interval, since last backup of the host. Maximum value is: 9999 days. See interval_type for available values. Exactly on of options should be set: execute_by_interval or execute_by_time.
  • execute_by_time (Block Set) Perform backup periodically at specific time. Exactly on of options should be set: execute_by_interval or execute_by_time. (see below for nested schema)
  • type (String) BackupSet type. See backup_set_type for available values. Default TYPE_AUTO.

Nested Schema for Nested Schema for scheduling.backup_sets.execute_by_time

Required:

  • type (String) Type of the scheduling. Available values are: HOURLY, DAILY, WEEKLY, MONTHLY.

Optional:

  • include_last_day_of_month (Boolean) If true, schedule will be applied on the last day of month. See day_type for available values. Default false.
  • monthdays (List of Number) List of days when schedule applies. Used in MONTHLY type.
  • months (List of Number) Set of values. Allowed values form 1 to 12.
  • repeat_at (List of String) List of time in format HH:MM (24-hours format), when the schedule applies.
  • repeat_every (String) Frequency of backup repetition. See interval_type for available values.
  • run_later (Boolean) If true and if the machine is off, launch missed tasks on boot up. Default false.
  • weekdays (List of String) List of weekdays when the backup will be applied. Used in WEEKLY type.

Nested Schema for Nested Schema for scheduling.execute_by_time

Required:

  • type (String) Type of the scheduling. Available values are: HOURLY, DAILY, WEEKLY, MONTHLY.

Optional:

  • include_last_day_of_month (Boolean) If true, schedule will be applied on the last day of month. See day_type for available values. Default false.
  • monthdays (List of Number) List of days when schedule applies. Used in MONTHLY type.
  • months (List of Number) Set of values. Allowed values form 1 to 12.
  • repeat_at (List of String) List of time in format HH:MM (24-hours format), when the schedule applies.
  • repeat_every (String) Frequency of backup repetition. See interval_type for available values.
  • run_later (Boolean) If true and if the machine is off, launch missed tasks on boot up. Default false.
  • weekdays (List of String) List of weekdays when the backup will be applied. Used in WEEKLY type.

Nested Schema for Nested Schema for vm_snapshot_reattempts

Optional:

  • enabled (Boolean) Enable flag. Default true.
  • interval (String) Retry interval. See interval_type for available values. Default: 5m.
  • max_attempts (Number) Maximum number of attempts before throwing an error. Default 5.

Nested Schema for Nested Schema for file_filters

Optional:

  • exclusion_masks (List of String) Do not backup files that match the following criteria.
  • inclusion_masks (List of String) Backup only files that match the following criteria.

Nested Schema for Nested Schema for timeouts

Optional:

  • create (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
  • delete (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
  • read (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.
  • update (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

ImportImport

The resource can be imported by using their resource ID. For getting the resource ID you can use Yandex Cloud Web Console or YC CLI.

# terraform import yandex_backup_policy.<resource Name> <Resource Id>
terraform import yandex_backup_policy.my_backup_policy ...

Была ли статья полезна?

Предыдущая
backup_policy
Следующая
backup_policy_bindings
Проект Яндекса
© 2025 ТОО «Облачные Сервисы Казахстан»