Updating a backup policy
Note
Backups are created based on the VM's or Yandex BareMetal server's local time. There may be a slight delay in the schedule depending on the current service load.
Updating basic settings
Warning
You cannot update backup policies with some advanced settings in the Yandex Cloud management console. To update the settings of such policies, use the Yandex Cloud CLI, Terraform, or API.
If the changes in the backup policy settings have not taken effect on the VM or BareMetal server the policy was associated with, unlink the policy from the VM and then link it again.
-
In the management console
, select the folder where you want to update a backup policy. -
In the list of services, select Cloud Backup.
-
In the left-hand panel, select
Backup policies. -
Click
next to the backup policy you want to update and select Edit. -
Edit the backup policy parameters:
-
Enter a name. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Under Launch settings, depending on the selected run schedule type configured when creating the policy:
-
Fixed schedule: Specify the backup frequency:Every day. Either once a day at a specified time or several times a day at a particular interval within the specified time period.Weekly. Select days of the week and time for backups on those days.Monthly. Specify months, day of the month, and time for backups.
For incremental backups, you can enable Create a full copy once a week and select the day of the week for a full backup. On the selected day, a full backup will be created instead of an incremental one.
-
Interval between backups: Specify the interval, in hours or days, between the end of the previous backup and the start of the new one.
Backups are created based on the VM's or BareMetal server's local time. There may be a slight delay in the schedule depending on the current service load.
-
-
Under Retention settings, set the backup retention policy:
-
Retain all copies: All backups created under this backup policy will be retained. -
Only the last: Specify the number of recent backups you want to retain or the number of days, weeks, or months for which to retain the backups. All other backups will be deleted automatically.Note
If you created the policy via the management console, subsequent updates of backup retention settings will take effect only after a next backup is created. If the changes have not taken effect, disassociate the policy from the VM or BareMetal server and then reassociate it.
-
-
Under Additional:
- Optionally, enable Run missed tasks after uploading to run all skipped backup jobs after the VM starts if the VM was
Stoppedduring the scheduled backup. This is only supported for incremental backups. - Optionally, enable Fast backup to speed up incremental backups. Changes in the file will be determined by size, date, and last update time. If the option is disabled, Cloud Backup will compare the contents of all files with the backup contents. This option does not work for volumes with JFS, ReiserFS3, ReiserFS4, ReFS, or XFS file systems.
- Optionally, enable Sector-by-sector backup to create an exact disk or volume backup at the physical level. Backs up all disk or volume sectors, including empty areas and unallocated space. If no compression level is selected, the backup size will be equal to the disk size. This mode is used automatically for disks with unsupported file systems. You cannot recover app data from a backup like that.
- Optionally, enable Backup checks to make sure you will be able to restore data from the backup. During the check, a checksum is calculated for each section available for recovery. The check may take a long time because it scans all recoverable data.
-
Optionally, enable Multivolume snapshot to create time-synchronized data backups spanning several volumes. This parameter decides whether snapshots of several volumes will be created simultaneously or one after another. Select your preferred method for creating snapshots:
Via Cloud Backup agent: Snapshot volumes using the Cloud Backup agent managed by LVM.Via LVM: Snapshot volumes using the built-in LVM tools. If the snapshot cannot be created using LVM, it will be created using the Cloud Backup agent.
-
Optionally, under Commands before and after, set the actions Cloud Backup will perform before and after the backup. To do this, enable Run the command before backup and/or Run the command after backup, and specify the following settings:
- Command or path to file: Command or path to the executable file that needs to be executed (run), e.g.,
/usr/bin/myapp. - Working folder: Working directory to execute the command (run the file) in, e.g.,
/etc/myapp/. - Arguments: Command line parameters that will be applied when executing the command (running the file), e.g.,
-d -rw. - Enable Terminate backup when a command fails to stop the backup if there is a command execution (file running) error.
Note
You can add to each policy not more than one command executed before the backup and not more than one executed after the backup.
- Command or path to file: Command or path to the executable file that needs to be executed (run), e.g.,
-
Optionally, under Repeat operation on task failure, specify the backup settings in the event of failure:
- Number of attempts: Maximum number of retry attempts. If reached, the operation is considered failed. Attempts will stop as soon as the operation succeeds or when the specified number of attempts is reached, whichever comes earlier.
This setting does not apply if the backup was started manually. - Time between attempts: Interval between reattempts.
- Number of attempts: Maximum number of retry attempts. If reached, the operation is considered failed. Attempts will stop as soon as the operation succeeds or when the specified number of attempts is reached, whichever comes earlier.
-
Optionally, under Error handling, configure the Cloud Backup behavior if errors occur:
-
Repeat operation on task failure: Reattempt settings in case of backup errors:
- Number of attempts: Maximum number of retry attempts.
- Time between attempts: Interval between reattempts.
-
Retry in case of an error while creating a snapshot: Reattempt settings in case of snapshot errors:
- Number of attempts: Maximum number of retry attempts.
- Time between attempts: Interval between reattempts.
-
-
Optionally, under File filters, you can use filters to exclude specific files and folders from your backups or do the opposite and back up only specific file system items:
- Do not backup files that meet the following criteria.
- Only backup files that meet the following criteria.
Exclusion filters take precedence over inclusion filters.
To include or exclude files, add some criteria, e.g., file names, paths, or masks.
*and?wildcards are supported. Use a new line for each criterion. Criteria are case-insensitive.
- Optionally, enable Run missed tasks after uploading to run all skipped backup jobs after the VM starts if the VM was
-
-
Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
See the description of the CLI command to update a backup policy:
yc backup policy update --help -
Specify backup policy configuration in JSON
format.Sample configuration file
{ "compression": "NORMAL", "format": "AUTO", "multiVolumeSnapshottingEnabled": true, "preserveFileSecuritySettings": true, "reattempts": { "enabled": true, "interval": { "type": "SECONDS", "count": "30" }, "maxAttempts": "30" }, "silentModeEnabled": true, "splitting": { "size": "1099511627776" }, "vmSnapshotReattempts": { "enabled": true, "interval": { "type": "MINUTES", "count": "5" }, "maxAttempts": "3" }, "vss": { "enabled": true, "provider": "TARGET_SYSTEM_DEFINED" }, "archive": { "name": "'[Machine Name]-[Plan ID]-[Unique ID]A'" }, "performanceWindow": { }, "retention": { "rules": [ { "maxCount": "10" } ], "beforeBackup": true }, "scheduling": { "backupSets": [ { "time": { "weekdays": [ "MONDAY" ], "repeatAt": [ { "minute": "5" } ], "type": "WEEKLY" } } ], "enabled": true, "maxParallelBackups": "2", "randMaxDelay": { "type": "MINUTES", "count": "30" }, "scheme": "ALWAYS_INCREMENTAL", "weeklyBackupDay": "MONDAY" }, "cbt": "ENABLE_AND_USE", "fastBackupEnabled": true, "quiesceSnapshottingEnabled": true, "prePostCommands": [ { "cmd": "/usr/bin/myapp", "args": "-d -rw", "enabled": true, "stopOnError": true, "type": "PRE_COMMAND", "wait": true, "workdir": "/etc/myapp/" } ] }The example describes a configuration for a backup policy that will create incremental VM or BareMetal server backups every Monday at 00:05 (UTC+0). Only the last 10 backups will be stored.
See the full backup policy specification for details.
-
Get the ID of the backup policy you want to update:
yc backup policy listResult:
+----------------------+----------------------+---------+---------+---------------------+---------------------+ | ID | FOLDER ID | NAME | ENABLED | CREATED AT | UPDATED AT | +----------------------+----------------------+---------+---------+---------------------+---------------------+ | abc7n3wln123******** | ghi681qpe789******** | policy1 | true | 2023-07-03 09:12:02 | 2023-07-03 09:12:43 | | deflqbiwc456******** | ghi681qpe789******** | policy2 | true | 2023-07-07 14:58:23 | 2023-07-07 14:58:23 | +----------------------+----------------------+---------+---------+---------------------+---------------------+ -
Update the backup policy by specifying its ID:
yc backup policy update <backup_policy_ID> \ --settings-from-file <path_to_configuration_file>Where
--settings-from-fileis the path to the backup policy configuration file in JSON format.Result:
id: cdgkoivuvtey******** name: sample-backup-policy created_at: "2025-10-06T19:09:31Z" updated_at: "2025-10-06T19:09:31Z" enabled: true settings: compression: NORMAL format: AUTO multi_volume_snapshotting_enabled: true reattempts: enabled: true interval: type: SECONDS count: "30" max_attempts: "30" silent_mode_enabled: true splitting: size: "1099511627776" vm_snapshot_reattempts: enabled: true interval: type: MINUTES count: "5" max_attempts: "3" vss: enabled: true provider: TARGET_SYSTEM_DEFINED archive: name: '''[Machine Name]-[Plan ID]-[Unique ID]A''' performance_window: {} retention: rules: - max_count: "10" before_backup: true scheduling: backup_sets: - time: weekdays: - MONDAY repeat_at: - minute: "5" type: WEEKLY type: TYPE_AUTO enabled: true max_parallel_backups: "2" rand_max_delay: type: MINUTES count: "30" scheme: ALWAYS_INCREMENTAL weekly_backup_day: MONDAY cbt: ENABLE_AND_USE fast_backup_enabled: true file_filters: {} pre_post_commands: - cmd: /usr/bin/myapp args: -d -rw enabled: true stop_on_error: true type: PRE_COMMAND wait: true workdir: /etc/myapp/ folder_id: b1gt6g8ht345********For more information about this command, see the CLI reference.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To edit the basic parameters of a backup policy:
-
Open the Terraform configuration file and edit the required settings in the
yandex_backup_policyresource description fragment:Below is an example with the description of the
yandex_backup_policyresource in the Terraform configurationresource "yandex_backup_policy" "my_policy" { archive_name = "[<VM_or_BareMetal_server_name>]-[<plan_ID>]-[<unique_ID>]" cbt = "USE_IF_ENABLED" compression = "NORMAL" fast_backup_enabled = true format = "AUTO" multi_volume_snapshotting_enabled = true name = "<backup_policy_name>" performance_window_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 { type = "MONTHLY" 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" weekdays = [] } } } vm_snapshot_reattempts { enabled = true interval = "1m" max_attempts = 10 } }For more information about
yandex_backup_policyproperties, see the relevant provider documentation. -
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
You can check the updates in the management console
or using this CLI command:yc backup policy get <backup_policy_ID> -
To update the basic parameters of a backup policy, use the update REST API method for the Policy resource or the PolicyService/Update gRPC API call.
Updating a list of VMs and Yandex BareMetal servers
- In the management console
, select the folder containing your backup policy. - In the list of services, select Cloud Backup.
- Navigate to the
Backup policies tab. - Select the backup policy where you want to edit the list of VMs or BareMetal servers.
- Edit the list of linked resources:
-
To link a new VM or BareMetal server, click
Attach a VM and in the window that opens:-
Depending on the resource you want to link to the backup policy, select the Virtual machines or BareMetal servers tab and select the VM or server from the list.
If the VM or BareMetal server you want to link to the backup policy is not listed, make sure it is connected to Cloud Backup.
-
Click Attach.
-
-
To unlink a VM or BareMetal server:
- Depending on the resource you want to unlink from the backup policy, select the Virtual machines or BareMetal servers tab.
- In the row with the VM or BareMetal server you want to unlink from the backup policy, click
and select Detach VM from policy or Detach server from policy, respectively. - In the window that opens, confirm this action.
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
Get the ID of the backup policy in which you want to edit the list of VMs or BareMetal servers:
yc backup policy listResult:
+----------------------+----------------------+---------+---------+---------------------+---------------------+ | ID | FOLDER ID | NAME | ENABLED | CREATED AT | UPDATED AT | +----------------------+----------------------+---------+---------+---------------------+---------------------+ | abc7n3wln123******** | ghi681qpe789******** | policy1 | true | 2023-07-03 09:12:02 | 2023-07-03 09:12:43 | | deflqbiwc456******** | ghi681qpe789******** | policy2 | true | 2023-07-07 14:58:23 | 2023-07-07 14:58:23 | +----------------------+----------------------+---------+---------+---------------------+---------------------+ -
Get the IDs of VMs you need to add or delete:
yc compute instance listResult:
+----------------------+---------+---------------+---------+--------------+-------------+ | ID | NAME | ZONE ID | STATUS | EXTERNAL IP | INTERNAL IP | +----------------------+---------+---------------+---------+--------------+-------------+ | jklp0o9i8012******** | my-vm-1 | ru-central1-b | RUNNING | 51.250.**.** | 192.168.*.* | | mnoa5s6d8345******** | my-vm-2 | ru-central1-b | RUNNING | 84.201.**.** | 192.168.*.* | +----------------------+---------+---------------+---------+--------------+-------------+To get the BareMetal server IDs, select BareMetal from the list of services of the relevant folder in the management console
. The IDs are specified in the server list in the ID field. -
Update the list of VMs and BareMetal servers in the backup policy.
-
To link a VM or BareMetal server to a backup policy:
View a description of the CLI command:
yc backup policy apply --helpLink your VMs or BareMetal servers to the backup policy by specifying its ID:
yc backup policy apply <backup_policy_ID> \ --instance-ids <VM_or_BareMetal_server_IDs>Where
--instance-idsare the IDs of the VMs or BareMetal servers connected to Cloud Backup you need to link to the backup policy. Multiple IDs should be comma-separated.For more information about this command, see the CLI reference.
-
To unlink VMs or BareMetal servers from a backup policy:
View a description of the CLI command:
yc backup policy revoke --helpUnlink your VMs or BareMetal servers from the backup policy by specifying its ID:
yc backup policy revoke <backup_policy_ID> \ --instance-ids <VM_or_BareMetal_server_IDs>Where
--instance-idsare the IDs of the VMs or BareMetal servers you need to unlink from the backup policy. Multiple IDs should be comma-separated.For more information about this command, see the CLI reference.
-
To edit the list of VMs or BareMetal servers backed up according to a backup policy, use the update REST API method for the Policy resource or the PolicyService/Update gRPC API call.