OCI SDK Full backup Block volumes

请确保已经成功配置了OCI cli SDK环境。

通过OCI python SDK实现全量备份:

https://docs.oracle.com/en-us/iaas/tools/python-sdk-examples/2.126.3/core/create_boot_volume_backup.py.html

代码例子:

# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

import oci

# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()


# Initialize service client with default config file
core_client = oci.core.BlockstorageClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
create_boot_volume_backup_response = core_client.create_boot_volume_backup(
    create_boot_volume_backup_details=oci.core.models.CreateBootVolumeBackupDetails(
        boot_volume_id="ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value",
        type="FULL"
       )

# Get the data from response
print(create_boot_volume_backup_response.data)

利用crontab实现周期备份

# Cron job example with every day 2 AM execution. 
0 2 * * * /usr/bin/python3 /home/opc/disk_fullbackup.py
Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *