# Full data migration - Export data to `Amazon S3`

```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.2.119  -B “<database>” -r 20000 --filetype csv --no-schemas -o “<directory of S3>”
# <database> : user,store,salesdb in instance1(host:10.90.2.119).
# <directory of S3> : s3://pe-class/user/instance1/,s3://pe-class/store/instance1/,s3://pe-class/salesdb/sales/instance1/ in s3.
```
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.1.84  -B <database> -r 20000 --filetype csv --no-schemas -o “<directory of S3>”
# <database> : user,store,salesdb in instance2(host:10.90.1.84).
# <directory of S3> : s3://pe-class/user/instance2/,s3://pe-class/store/instance2/,s3://pe-class/salesdb/sales/instance2/ in s3.
```
-------------------------------------------------------------
We use Dumping to export data from `MySQL` (`instance1` and `instance2`) to `Amazon S3`.
Please note the following:
1. Enable binlog for `MySQL`.
2. Choose the correct `Amazon S3` directory and region.
3. Choose the appropriate concurrency by configuring the `-t` option to minimize the impact on the `MySQL`, or export directly from the backup database. 
4. Set appropriate values for `--filetype csv` and `--no-schemas`. 
For more information about how to use these parameters, see https://docs.pingcap.com/tidb/stable/dumpling-overview#option-list-of-dumpling
Please refer to the documentation for more information on how to use `Dumpling`: https://docs.pingcap.com/tidb/stable/dumpling-overview

To export data to `Amazon S3`, do the following:
(1) Export database `user` from `MySQL instance1` to the `s3://pe-class/user/instance1/` directory in the `Amazon S3 bucket`.
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.2.119  -B user -r 20000 --filetype csv --no-schemas -o s3://pe-class/user/instance1/
```

(2) Export database `store` from `MySQL instance1` to the `s3://pe-class/store/instance1/` directory in the `Amazon S3 bucket`.
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.2.119  -B store -r 20000 --filetype csv --no-schemas -o s3://pe-class/store/instance1/
```

(3) Export database `salesdb` from `MySQL instance1` to the `s3://pe-class/salesdb/sales/`instance1/ directory in the `Amazon S3 bucket`.
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.2.119  -B salesdb -r 20000 --filetype csv --no-schemas -o s3://pe-class/salesdb/sales/instance2/
```

(4) Export database `user` from `MySQL instance2` to the `s3://pe-class/user/instance2/` directory in the `Amazon S3 bucket`.
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.1.84  -B user -r 20000 --filetype csv --no-schemas -o s3://pe-class/user/instance2/
```

(5) Export database `store` from `MySQL instance2` to the `s3://pe-class/store/instance2/` directory in the `Amazon S3 bucket`.
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.1.84  -B store -r 20000 --filetype csv --no-schemas -o s3://pe-class/store/instance2/
```

(6) Export database `salesdb` from `MySQL instance2` to the `s3://pe-class/salesdb/sales/instance2/` directory in the `Amazon S3 bucket`.
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.1.84  -B salesdb -r 20000 --filetype csv --no-schemas -o s3://pe-class/salesdb/sales/instance2/
```

If you need to obtain data snapshots of all databases at the same moment, you can export multiple copies of data simultaneously, as below:
```
tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.2.119  -B user, store, salesdb -r 20000 --filetype csv --no-schemas -o s3://pe-class/instance1/

tiup dumpling -u dm_user -p'q1w2e3R4_' -P 3306 -h 10.90.1.84  -B user, store, salesdb-r 20000 --filetype csv --no-schemas -o s3://pe-class/instance2/
```

For detailed, see：https://docs.pingcap.com/tidb/stable/dumpling-overview#export-data-to-amazon-s3-cloud-storage