Linking a VM or Yandex BareMetal server to a backup policy
You can only link a VM or BareMetal server to a backup policy if they are connected to Yandex Cloud Backup. For more information, see Managing VMs in Cloud Backup and Managing BareMetal servers in Cloud Backup.
-
In the management console
, select a folder where you want to link a VM or BareMetal server to a backup policy. -
Go to Cloud Backup.
-
Navigate to the
Backup policies tab. -
Select the policy to link the VM or BareMetal server to.
-
Under Attached resources, 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.
-
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
View the description of the CLI command to link a VM or BareMetal server to a backup policy:
yc backup policy apply --help -
Get the ID of the policy to link the VM or BareMetal server to:
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 ID of the VM to link:
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. -
Link the VM or BareMetal server by the policy ID:
yc backup policy apply <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.
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.
Note
Currently, you can only associate a Compute Cloud VM instance with a backup policy using Terraform. To associate a BareMetal server, use the management console
To associate a VM with a backup policy:
-
In the Terraform configuration file, describe the parameters for associating the VM with the policy:
resource "yandex_backup_policy_bindings" "test_backup_binding" { instance_id = "<VM_ID>" policy_id = "<policy_ID>" }Where:
instance_id: ID of the VM you want to associate with the policy.policy_id: ID of the policy to associate the VM with.
For more information about
yandex_backup_policy_bindingsproperties, see the relevant provider documentation. -
Create the resources:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check the new resources using the management console
or this CLI command:yc backup policy list-applications -
Use the apply REST API method for the Policy resource or the PolicyService/Apply gRPC API call.