# Logical Backups

+ Full backup or export by using `Dumpling`
+ Logical backups are the slowest among all the backup techniques 
+ The process creates a `SQL` script that you can execute on a TiDB server
+ You can use the script to reload the database on a cluster with different configuration  
+ You can use **`--consistency`** flag to control the backup types
  + **`auto`** or **`snapshot`** is **`Hot`** backup and consistency is guaranteed (default)
  + **`none`** is **`Hot`** backup and consistency is not guaranteed
  + **`lock`** and **`flush`** are **`Warm`** backup and it depends on `TiDB` parameter **`enable-table-lock`**
+ For example:
```
$ tiup dumpling --consistency snapshot
...
[2022/10/19 15:27:30.100 +08:00] [INFO] [client.go:397] ["[pd] create pd client with endpoints"]
  [pd-address="[127.0.0.1:2382,127.0.0.1:2379,127.0.0.1:2384]"]
...
[2022/10/19 15:27:30.105 +08:00] [INFO] [client.go:690] ["[pd] tso dispatcher created"] [dc-location=global]
[2022/10/19 15:27:30.108 +08:00] [INFO] [dump.go:1460] ["generate dumpling gc safePoint id"] [id=dumpling_1666164450108582000]
[2022/10/19 15:27:30.146 +08:00] [INFO] [dump.go:127] ["begin to run Dump"]
...
[2022/10/19 15:27:30.380 +08:00] [INFO] [collector.go:239] ["backup success summary"] [total-ranges=10] [ranges-succeed=10]
  [ranges-failed=0] [total-take=87.120219ms] [total-kv-size=3.598kB] [average-speed=41.3kB/s] [total-rows=43]
[2022/10/19 15:27:30.381 +08:00] [INFO] [client.go:771] ["[pd] stop fetching the pending tso requests due to context canceled"]
  [dc-location=global]
[2022/10/19 15:27:30.381 +08:00] [INFO] [client.go:709] ["[pd] exit tso dispatcher"] [dc-location=global]
[2022/10/19 15:27:30.381 +08:00] [INFO] [main.go:81] ["dump data successfully, dumpling will exit now"]
```

--------------------------------------------------------------------------------------------
Advantage of logical backup:
- You can check the integrity of the backup by simply reading the backup results.
- Logical backup can be used to import data to other database systems (as long as SQL is supported).

Disadvantage of logical backup:
- Time consuming when performing the backup and restoring the data.

Logical backup characteristics:
- Converting databases and tables to `SQL` statements.
- Easy to read and migration.
- Requires that the `TiDB` is running during the backup process.
- Can back up `TiDB` remotely.
- Typically slower than the physical backups.
- The size of the logical backup file may exceed the size of the database being backed up.
- Statements may take up more space than the data they represent.

Mode details about `Dumpling` is covered in the next unit.
