Backup Task

Last updated: 2023-09-01 17:40:33

API
Description
CreateBackup
Creates a TencentDB instance backup
DeleteBackup
Deleting a TencentDB instance backup
DescribeBackupConfig
This API shows you how to query the configuration information of a TencentDB instance backup.
DescribeBackups
This example shows you how to query the list of data backup files.
DescribeBinlogs
This example shows you how to query a binlog.
DescribeSlowLogs
Querying slow logs
ModifyBackupConfig
This example shows you how to modify the database backup configuration.

CreateBackup: Creating a TencentDB instance backup

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

# Introduce the Cloud API entry module

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

try:
Instantiate an authentication object, passing in the Tencent Cloud account SecretId and SecretKey as parameters
cred = credential.Credential("secretId", "secretKey")

Instantiate a client object for the desired product (using cdb as an example)
client = cdb_client.CdbClient(cred, "ap-shanghai")

Instantiate a request object: req = models.ModifyInstanceParamRequest()
req = models.CreateBackupRequest()
req.InstanceId = "cdb-7ghaiocc"
req.BackupMethod = "logical"

print req
Invoke the desired API through the client object by passing in the request object
resp = client.CreateBackup(req)

Returns a JSON-formatted response string
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DeleteBackup: Deleting a TencentDB instance backup

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

# Introduce the Cloud API entry module

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

try:
Instantiate an authentication object, passing in the Tencent Cloud account SecretId and SecretKey as parameters
cred = credential.Credential("secretId", "secretKey")

Instantiate a client object for the desired product (using cdb as an example)
client = cdb_client.CdbClient(cred, "ap-shanghai")



Instantiate a request object: req = models.ModifyInstanceParamRequest()
req = models.DeleteBackupRequest()

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


Invoke the desired API through the client object by passing in the request object
resp = client.DeleteBackup(req)

Returns a JSON-formatted response string
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DescribeBackupConfig: Querying the configuration information of a TencentDB instance backup

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

# Introduce the Cloud API entry module

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

try:
Instantiate an authentication object, passing in the Tencent Cloud account SecretId and SecretKey as parameters
cred = credential.Credential("secretId", "secretKey")

Instantiate a client object for the desired product (using cdb as an example)
client = cdb_client.CdbClient(cred, "ap-shanghai")

Instantiate a request object: req = models.ModifyInstanceParamRequest()
req = models.DescribeBackupConfigRequest()
req.InstanceId = "cdb-7ghaiocc"

print req
Invoke the desired API through the client object by passing in the request object
resp = client.DescribeBackupConfig(req)

Returns a JSON-formatted response string
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DescribeBackups: Query the list of data backup files

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

# Introduce the Cloud API entry module

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

try:
Instantiate an authentication object, passing in the Tencent Cloud account SecretId and SecretKey as parameters
cred = credential.Credential("secretId", "secretKey")

Instantiate a client object for the desired product (using cdb as an example)
client = cdb_client.CdbClient(cred, "ap-shanghai")

Instantiate a request object: req = models.ModifyInstanceParamRequest()
req = models.DescribeBackupsRequest()
req.InstanceId = "cdb-7ghaiocc"



Invoke the desired API through the client object by passing in the request object
resp = client.DescribeBackups(req)
print resp

Returns a JSON-formatted response string
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)

DescribeBinlogs: Querying binary logs

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

# Introduce the Cloud API entry module

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

try:
Instantiate an authentication object, passing in the Tencent Cloud account SecretId and SecretKey as parameters
cred = credential.Credential("secretId", "secretKey")

Instantiate a client object for the desired product (using cdb as an example)
client = cdb_client.CdbClient(cred, "ap-shanghai")

Instantiate a request object: req = models.ModifyInstanceParamRequest()
req = models.DescribeBinlogsRequest()
req.InstanceId = "cdb-7ghaiocc"


Invoke the desired API through the client object by passing in the request object
resp = client.DescribeBinlogs(req)

Returns a JSON-formatted response string
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)


DescribeSlowLogs: Querying slow query logs

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

# Introduce the Cloud API entry module

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

try:
Instantiate an authentication object, passing in the Tencent Cloud account SecretId and SecretKey as parameters
cred = credential.Credential("secretId", "secretKey")

Instantiate a client object for the desired product (using cdb as an example)
client = cdb_client.CdbClient(cred, "ap-shanghai")

Instantiate a request object: req = models.ModifyInstanceParamRequest()
req = models.DescribeSlowLogsRequest()
req.InstanceId = "cdb-7ghaiocc"


Invoke the desired API through the client object by passing in the request object
resp = client.DescribeSlowLogs(req)

Returns a JSON-formatted response string
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)


ModifyBackupConfig: Modify the TencentDB instance backup configuration

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

# Introduce the Cloud API entry module

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

try:
Instantiate an authentication object, passing in the Tencent Cloud account SecretId and SecretKey as parameters
cred = credential.Credential("secretId", "secretKey")

Instantiate a client object for the desired product (using cdb as an example)
client = cdb_client.CdbClient(cred, "ap-shanghai")

Instantiate a request object: req = models.ModifyInstanceParamRequest()
req = models.ModifyBackupConfigRequest()
req.InstanceId = "cdb-1y6g3zj8"
req.ExpireDays = 10
req.StartTime = "06:00-10:00"
req.BackupMethod = "logical"
print req


Invoke the desired API through the client object by passing in the request object
resp = client.ModifyBackupConfig(req)

Returns a JSON-formatted response string
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)