[id='cross-site-state-transfer_{context}']
= State transfer
State transfer is an administrative operation that synchronizes data between clusters.

For example, **LON** goes offline and **NYC** starts handling client requests.
When you bring **LON** back online, the {brandname} cluster in **LON** does not
have the same data as the cluster in **NYC**.

To ensure the data is consistent between **LON** and **NYC**, you can push
state from **NYC** to **LON**.

* State transfer is bidirectional.
For example, you can push state from **NYC** to **LON** or from **LON** to **NYC**.
* Pushing state to offline clusters brings them back online.
* State transfer overwrites only data that exists on both cluster and does not delete data.
+
For example, "k2" exists on **LON** and **NYC**.
"k2" is removed from **NYC** while **LON** is offline.
When you bring **LON** back online, "k2" still exists at that location.
If you push state from **NYC** to **LON**, the transfer does not affect "k2" on **LON**.

[TIP]
====
To ensure the contents of the cache are identical after state transfer, remove all data from the cache on the receiving cluster before pushing state.

Use the `clear()` method or the [command]`clearcache` command from the CLI.
====

* State transfer does not overwrite updates to data that occur after you
initiate the push.
+
For example, "k1,v1" exists on **LON** and **NYC**.
**LON** goes offline, so you push state transfer to **LON** from **NYC**, which brings **LON** back online.
Before state transfer completes, a client puts "k1,v2" on **LON**.
+
In this scenario, the state transfer from **NYC** does not overwrite "k1,v2" because
that modification happened after you initiated the push.

[discrete]
== Automatic state transfer

By default, you must manually perform cross-site state transfer operations with the CLI or via JMX or REST.

However, when using the asynchronous backup strategy, {brandname} can automatically perform cross-site state transfer operations.

When a backup location comes back online, and the network connection is stable, {brandname} initiates bidirectional state transfer between backup locations.
For example, {brandname} simultaneously transfers state from **LON** to **NYC** and **NYC** to **LON**.

[NOTE]
====
To avoid temporary network disconnects triggering state transfer operations, there are two conditions that backup locations must meet to go offline.
The status of a backup location must be offline and it must not be included in the cross-site view.
====

The automatic state transfer is also triggered when a cache starts.

In the scenario where **LON** is starting up, after a cache starts, it sends a notification to **NYC**.
Following this, **NYC** starts a unidirectional state transfer to **LON**.

[role="_additional-resources"]
.Additional resources
* link:../../apidocs/org/infinispan/Cache.html#clear()[org.infinispan.Cache.clear()]
* link:{cli_docs}[Using the {brandname} Command Line Interface]
* link:{rest_docs}[Using the {brandname} REST API]
