备份任务

最近更新时间:2024-10-17 22:03:12

我的收藏
API
描述
CreateBackup
创建云数据库备份
DeleteBackup
删除云数据库备份
DescribeBackupConfig
查询云数据库备份配置信息
DescribeBackups
查询数据备份文件列表
DescribeBinlogs
查询二进制日志
DescribeSlowLogs
查询慢查询日志
ModifyBackupConfig
修改数据库备份配置

CreateBackup 创建云数据库备份

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 引入云API入口模块

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdb.v20170320 import cdb_client, models

try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")

#实例化要请求产品(以cdb为例)的client对象
client = cdb_client.CdbClient(cred, "ap-shanghai")

#实例化一个请求对象:req = models.ModifyInstanceParamRequest()
req = models.CreateBackupRequest()
req.InstanceId = "cdb-7ghaiocc"
req.BackupMethod = "logical"

print req
# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.CreateBackup(req)

# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DeleteBackup 删除云数据库备份

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 引入云API入口模块

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdb.v20170320 import cdb_client, models

try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")

#实例化要请求产品(以cdb为例)的client对象
client = cdb_client.CdbClient(cred, "ap-shanghai")



#实例化一个请求对象:req = models.ModifyInstanceParamRequest()
req = models.DeleteBackupRequest()

req.InstanceId = "cdb-7ghaiocc"
#print req.BackupId
req.BackupId = 105119782


# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.DeleteBackup(req)

# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DescribeBackupConfig 查询云数据库备份配置信息

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 引入云API入口模块

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdb.v20170320 import cdb_client, models

try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")

#实例化要请求产品(以cdb为例)的client对象
client = cdb_client.CdbClient(cred, "ap-shanghai")

#实例化一个请求对象:req = models.ModifyInstanceParamRequest()
req = models.DescribeBackupConfigRequest()
req.InstanceId = "cdb-7ghaiocc"

print req
# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.DescribeBackupConfig(req)

# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DescribeBackups 查询数据备份文件列表

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 引入云API入口模块

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdb.v20170320 import cdb_client, models

try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")

#实例化要请求产品(以cdb为例)的client对象
client = cdb_client.CdbClient(cred, "ap-shanghai")

#实例化一个请求对象:req = models.ModifyInstanceParamRequest()
req = models.DescribeBackupsRequest()
req.InstanceId = "cdb-7ghaiocc"



# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.DescribeBackups(req)
print resp

# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DescribeBinlogs 查询二进制日志

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 引入云API入口模块

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdb.v20170320 import cdb_client, models

try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")

#实例化要请求产品(以cdb为例)的client对象
client = cdb_client.CdbClient(cred, "ap-shanghai")

#实例化一个请求对象:req = models.ModifyInstanceParamRequest()
req = models.DescribeBinlogsRequest()
req.InstanceId = "cdb-7ghaiocc"


# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.DescribeBinlogs(req)

# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)


DescribeSlowLogs 查询慢查询日志

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 引入云API入口模块

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdb.v20170320 import cdb_client, models

try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")

#实例化要请求产品(以cdb为例)的client对象
client = cdb_client.CdbClient(cred, "ap-shanghai")

#实例化一个请求对象:req = models.ModifyInstanceParamRequest()
req = models.DescribeSlowLogsRequest()
req.InstanceId = "cdb-7ghaiocc"


# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.DescribeSlowLogs(req)

# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)


ModifyBackupConfig 修改数据库备份配置

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 引入云API入口模块

from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdb.v20170320 import cdb_client, models

try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
cred = credential.Credential("secretId", "secretKey")

#实例化要请求产品(以cdb为例)的client对象
client = cdb_client.CdbClient(cred, "ap-shanghai")

#实例化一个请求对象:req = models.ModifyInstanceParamRequest()
req = models.ModifyBackupConfigRequest()
req.InstanceId = "cdb-1y6g3zj8"
req.ExpireDays = 10
req.StartTime = "06:00-10:00"
req.BackupMethod = "logical"
print req


# 通过client对象调用想要访问的接口,需要传入请求对象
resp = client.ModifyBackupConfig(req)

# 输出json格式的字符串回包
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)