# 复制UFS数据

## Copy UFS Data

分布式文件复制允许用户高效地将数据从一个UFS复制到另外一个UFS。 这可用于两个UFS之间数据的搬迁和同步。

### 使用方法

有两种触发分布式复制文件的方法：

#### 任务加载 CLI

CLI 会向 Alluxio coordinator 发送复制请求，coordinator 随后会将需要复制的文件分发到所有 worker 节点。

````shell
bin/alluxio job copy [flags]
- 操作一个copy任务：
```shell
$ {ALLUXIO_HOME}/bin/alluxio job copy --src s3://bucket/src --dst s3://bucket/dst --[submit|progress|stop]

$ {ALLUXIO_HOME}/bin/alluxio job copy --local-index-file /indexfile --[submit|progress|stop]

$ {ALLUXIO_HOME}/bin/alluxio job copy --ufs-index-file s3://bucket/indexfile --[submit|progress|stop]
````

## 输出示例

Progress for jobId 1c849041-ef26-4ed7-a932-2af5549754d7 copying path '/src' to '/dst': Settings: "check-content: false" Job Submitted: 2023-06-30 12:30:45.0 Job Id: 111111 Job State: RUNNING Files qualified so far: 1, 826.38MB Files Failed: 0 Files Skipped: 0 Files Succeeded: 1 Bytes Copied: 826.38MB Throughput: 1621.09KB/s Files failure rate: 0.00%

````

有关 CLI 的详细用法，请参阅 [job copy](../reference/User-CLI.md) 文档。

### REST API

与 CLI 类似，REST API 也可用于数据复制。
请求直接发送到coordinator。

```shell
curl -H "Content-Type: application/json"  -v -X POST http://coordinator_host:19999/api/v1/master/submit_job/copy -d '{
  "src": "s3://alluxiow/testm/dir-1/dir1",
  "dst": "s3://alluxiow/testm/dir-1/dir2",
  "options": {
    "batchSize": "300",
    "check_content": "true"
  }
}'
````

可以通过发送路径相同的 GET 请求查询参数来检查进度。

```shell
curl -H "Content-Type: application/json"  -v -X GET http://coordinator_host:19999/api/v1/master/progress_job/copy -d '{
  "src": "s3://alluxiow/testm/dir-1/dir1",
  "dst": "s3://alluxiow/testm/dir-1/dir2",
  "format": "TEXT[default] | JSON",
  "verbose": "true"
}'
```

可以通过相同路径发送 POST 请求来终止加载操作。

```shell
curl -H "Content-Type: application/json"  -v -X POST http://coordinator_host:19999/api/v1/master/stop_job/copy -d '{
  "src": "s3://alluxiow/testm/dir-1/dir1",
  "dst": "s3://alluxiow/testm/dir-1/dir2"
}'
```

查询copy任务列表，结果仅包含七天内的load任务， 历史任务驻留时间可以通过`alluxio.job.retention.time`配置。

```shell
curl http://coordinator_host:19999/api/v1/master/list_job?[job-type=COPY[&job-state=[RUNNING|VERIFYING|STOPPED|SUCCEEDED|FAILED|ALL]]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.alluxio.io/ee-ai-cn/ai-3.5/transfer/copy-ufs-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
