# Using TiUP for Patch Upgrades (hotfixes)

__*TiDB patch upgrade*__
__*TiUP hotfix*__
__*tiup cluster patch*__

+ Upgrade all TiDB instances on a cluster
  + `tiup cluster patch ${cluster-name} /tmp/tidb-hotfix.tar.gz -R tidb`

+ Replacing one of your TiDB instances
  + `tiup cluster patch ${cluster-name} /tmp/tidb-hotfix.tar.gz -N ${Node_IP}:${Node_Port}`

-------------------------------------------------------------
In some scenario (such as Debug), you may need to replace the running component with a temporary package provided by the support team. In this case, you can use the patch command from TiUP:

tiup cluster patch —help
Replace the remote package with a specified package and restart the service

Usage:
  tiup cluster patch <cluster-name><package-path>[flags]

Flags:
  -h, —help help
  -N, —node strings specify the node to be replaced
      —overwrite Use the currently specified temporary package in future scale-out operations
  -R, —role strings specify the service type to be replaced
      —transfer-timeout int transfer leader time-out

Global Flags:
      —native-ssh uses the system's default SSH client
      —wait-timeout int Time to wait for the operation to time out
      —ssh-timeout int timeout for SSH connections
  -y, —yes skip all confirmation steps

For example, there is a TiDB instance where the hotfix package is placed in the /tmp/tidb-hotfix.tar.gz directory. If you want to replace all TiDB instances on the cluster at this point, you can execute the following command:
tiup cluster patch $ {cluster-name} /tmp/tidb-hotfix.tar.gz -R tidb

Or just replace one of the TiDB instances:
tiup cluster patch $ {cluster-name} /tmp/tidb-hotfix.tar.gz -N $ {node*IP}: $ {Node*port}