# Cleaning Up `TiDB` Cluster Data (On-premises)

__*zz-BGL*__

+ To reset the cluster back to the state as it has been just deployed, which means deleting all data. 
+ Use following command combinations to clean the cluster data:
  + **`tiup cluster clean {cluster_name} {option}`**
  + **`--log:`** Clean up logs
  + **`--data:`** Clean up data
  + **`--all:`** Clean both logs and data
+ Caution: **`clean`** operation cannot be undone
+ For examples:
```
$ tiup cluster clean {cluster_name} --log

$ tiup cluster clean {cluster_name} --data

$ tiup cluster clean {cluster_name} --all

$ tiup cluster clean {cluster-name} --all --ignore-role prometheus

$ tiup cluster clean {cluster_name} --all --ignore-node 172.16.13.12
```

-------------------------------------------------------------
In the test environment, sometimes you might need to reset the cluster back to the state as it has been just deployed, which means deleting all data. You can do that easily using the `tiup cluster clean` command. After running it, the cluster is stopped and then cluster data is deleted. After restarting the cluster manually, you will get a clean cluster.

Warning: This command will first stop the cluster even if you choose only to clean up logs. Therefore, do not use it in a production environment.


Delete the logs of all services in the cluster, while keep the data:
```
$ tiup cluster clean {cluster_name} --log
```

Delete the data of all services in the cluster, while keep the logs:
```
$ tiup cluster clean {cluster_name} --data
```

Delete the data and logs of all services in the cluster:
```
$ tiup cluster clean {cluster_name} --all
```

Clear logs and data for all services other than `Prometheus`:
```
$ tiup cluster clean {cluster-name} --all --ignore-role prometheus
```

Purge logs and data for all services deployed other than `172.16.13.12`:
```
$ tiup cluster clean {cluster_name} --all --ignore-node 172.16.13.12
```