Updated on 2025-08-05 GMT+08:00

Stopping a Data Migration Task

Function

This API is used to stop a data migration task.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/migration-task/{task_id}/stop

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition:

Project ID. For details, see Obtaining a Project ID.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

task_id

Yes

String

Definition:

ID of the data migration task.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

task_id

String

Definition:

Migration task ID.

Range:

N/A

task_name

String

Definition:

Name of the migration task.

Range:

N/A

description

String

Definition:

Description of the migration task.

Range:

N/A

status

String

Definition:

Status of the migration task.

Range:

  • SUCCESS: The task succeeded.

  • FAILED: The task failed.

  • MIGRATING: Migration is in progress.

  • TERMINATED: The task has stopped.

  • TERMINATING: The task is being stopped.

  • INCRMIGEATING: Incremental migration is in progress.

  • FULLMIGRATING: Full migration is in progress.

  • RUNNING: The task is to be configured.

  • MIGRATION_FAILED: The migration failed.

  • RELEASED: The task has been released.

migration_type

String

Definition:

Description of the migration task.

Range:

  • backupfile_import: backup import

  • online_migration: online migration

migration_method

String

Definition:

Type of the migration.

Range:

  • full_amount_migration: full migration

  • incremental_migration: online migration

ecs_tenant_private_ip

String

Definition:

Private IP address of the migration ECS on the tenant side. This IP address can be added to the whitelist if it is in the same VPC as the private IP address of the target or source Redis.

Range:

N/A

backup_files

BackupFilesRespBody object

Definition:

Backup files to be imported when the migration mode is backup file import.

network_type

String

Definition:

Network type. The value can be vpc or vpn.

Range:

  • vpc

  • vpn

source_instance

SourceInstanceRespBody object

Definition:

Source Redis information.

target_instance

TargetInstanceRespBody object

Definition:

Target Redis instance information.

created_at

String

Definition:

Time when the migration task is created.

Range:

N/A

updated_at

String

Definition:

Time when the migration task is complete.

Range:

N/A

released_at

String

Definition:

Time when the migration ECS is released.

Range:

N/A

version

String

Definition:

Version of the migration ECS.

Range:

N/A

resume_mode

String

Definition:

Data migration mode.

Range:

  • auto: automatic migration

  • manual: manual migration

supported_features

Array of strings

Definition:

Supported features.

Range:

N/A

tenant_vpc_id

String

Definition:

VPC ID.

Range:

N/A

tenant_subnet_id

String

Definition:

Subnet ID.

Range:

N/A

tenant_security_group_id

String

Definition:

Security group ID.

Range:

N/A

bandwidth_limit_mb

String

Definition:

Maximum bandwidth.

Range:

N/A

task_status

String

Definition:

Task status. EXCHANGING is returned only when IP addresses are being switched.

Range:

EXCHANGING: IP addresses are being switched.

Table 3 BackupFilesRespBody

Parameter

Type

Description

file_source

String

Definition:

Data source, which can be an OBS bucket or a backup record.

Range:

  • self_build_obs: OBS bucket data.

  • backup_record: Redis backup file.

bucket_name

String

Definition:

OBS bucket name.

Range:

N/A

files

Array of FilesResp objects

Definition:

List of backup files to be imported.

backup_id

String

Definition:

Backup record ID.

Range:

N/A

Table 4 FilesResp

Parameter

Type

Description

file_name

String

Definition:

Name of a backup file.

Range:

N/A

size

String

Definition:

File size in bytes.

Range:

N/A

update_at

String

Definition:

Time when the file is last modified. The format is YYYY-MM-DD HH:MM:SS.

Range:

N/A

Table 5 SourceInstanceRespBody

Parameter

Type

Description

addrs

String

Definition:

IP address and domain name of the Redis instance.

Range:

N/A

password

String

Definition:

Redis password.

Range:

N/A

id

String

Definition:

Redis instance ID.

Range:

N/A

ip

String

Definition:

Redis IP address.

Range:

N/A

port

String

Definition:

Redis port.

Range:

N/A

name

String

Definition:

Redis name.

Range:

N/A

proxy_multi_db

Boolean

Definition:

Indicates whether multi-DB is enabled for Proxy Cluster DCS instances.

Range:

  • true: Yes

  • false: No

db

String

Definition:

Redis database.

Range:

0–255

withProxy

Boolean

Definition:

Indicates whether proxy nodes are available.

Range:

  • true: Yes

  • false: No

Table 6 TargetInstanceRespBody

Parameter

Type

Description

addrs

String

Definition:

Source Redis address (specified in the source_instance parameter).

Range:

N/A

password

String

Definition:

Redis password.

Range:

N/A

id

String

Definition:

Redis instance ID.

Range:

N/A

ip

String

Definition:

Redis IP address.

Range:

N/A

port

String

Definition:

Redis port.

Range:

N/A

name

String

Definition:

Redis name.

Range:

N/A

proxy_multi_db

Boolean

Definition:

Indicates whether multi-DB is enabled for Proxy Cluster DCS instances.

Range:

  • true: Yes

  • false: No

db

String

Definition:

Redis database.

Range:

0–255

withProxy

Boolean

Definition:

Indicates whether proxy nodes are available.

Range:

  • true: Yes

  • false: No

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 404

Table 10 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Example Requests

POST https://{dcs_endpoint}/v2/666486c2d9b948c1bbea57e714d744fa/migration-task/2fb6b7e2-5eb8-4380-9d60-ce8d12b19aca/stop

Example Responses

Status code: 200

Data migration task stopped successfully.

{
  "task_name" : "migration1",
  "task_id" : "a276c1ffa0a54c2597fc824b917db317",
  "status" : "TERMINATING",
  "migration_type" : "incremental_migration",
  "network_type" : "vpc",
  "source_instance" : {
    "addrs" : "192.168.1.2:6379",
    "id" : "86157b69-8a62-47f9-8c55-fa6ddc8927e1",
    "name" : "dcs-test",
    "ip" : "192.168.1.2",
    "port" : "6379",
    "proxy_multi_db" : false,
    "password" : "DCStest123",
    "db" : "0"
  },
  "target_instance" : {
    "addrs" : "192.168.1.2:6379",
    "id" : "86157b69-8a62-47f9-8c55-fa6ddc8927ee",
    "name" : "test-instance",
    "ip" : "192.168.1.2",
    "port" : "6379",
    "proxy_multi_db" : false,
    "password" : "DCStest123",
    "db" : "0"
  },
  "created_at" : "2019/10/22 14:44:30",
  "updated_at" : "2019/10/22 18:00:00"
}

SDK Sample Code

The SDK sample code is as follows.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dcs.v2.region.DcsRegion;
import com.huaweicloud.sdk.dcs.v2.*;
import com.huaweicloud.sdk.dcs.v2.model.*;


public class StopMigrationTaskSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        DcsClient client = DcsClient.newBuilder()
                .withCredential(auth)
                .withRegion(DcsRegion.valueOf("<YOUR REGION>"))
                .build();
        StopMigrationTaskRequest request = new StopMigrationTaskRequest();
        request.withTaskId("{task_id}");
        try {
            StopMigrationTaskResponse response = client.stopMigrationTask(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdcs.v2.region.dcs_region import DcsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdcs.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = DcsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DcsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = StopMigrationTaskRequest()
        request.task_id = "{task_id}"
        response = client.stop_migration_task(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dcs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dcs/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dcs/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dcs/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := dcs.NewDcsClient(
        dcs.DcsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.StopMigrationTaskRequest{}
	request.TaskId = "{task_id}"
	response, err := client.StopMigrationTask(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Data migration task stopped successfully.

400

Invalid request.

401

Invalid authentication information.

403

The request is rejected.

404

The requested resource is not found.

500

Internal service error.

Error Codes

See Error Codes.