云主机备份服务是一种用于保护云主机数据的服务,通过对云主机的系统盘和数据盘进行定期备份,确保在数据丢失或损坏时能够快速恢复。该服务通常提供自动备份和手动备份两种方式,并支持按需恢复。
import tencentcloud.common.credentials
import tencentcloud.common.profile
import tencentcloud.cvm.v20170312.cvm_client
def create_backup(backup_name, instance_id):
cred = tencentcloud.common.credentials.Credentials("your_secret_id", "your_secret_key")
client = tencentcloud.cvm.v20170312.cvm_client.CvmClient(cred, "ap-guangzhou")
req = tencentcloud.cvm.v20170312.models.CreateBackupRequest()
params = {
"BackupName": backup_name,
"InstanceId": instance_id
}
req.from_json_string(params)
resp = client.CreateBackup(req)
return resp.to_json_string(indent=2)
# 示例调用
backup_name = "my_backup"
instance_id = "ins-8kb67vwe"
result = create_backup(backup_name, instance_id)
print(result)
领取专属 10元无门槛券
手把手带您无忧上云