Add a Replication

An XDCR replication allows bucket data to be replicated continuously from a specified bucket on a source cluster to a specified bucket on a target cluster.

An XDCR replication is created on the cluster that is to be the source of the data-replication. This cluster is known as the source cluster, and it contains the data that you want to replicate. Each replication targets a bucket on a different cluster, known as the destination cluster, in which the data will be replicated.

Prerequisites

The procedures on this page assume the following:

  • You have identified/created both a destination cluster and a destination bucket on that cluster to replicate data to

  • You have one of the following roles:

    • Organization Admin

    • Organization Edit

    • Project Edit (for the projects that contain the source cluster and the destination cluster)

Add a Replication Between Clusters in Couchbase Cloud

  1. Go to the source cluster’s Replication tab.

    Click the Projects tab in the left navigation, then click on the project that contains the cluster. In the project’s slide-out menu, click the cluster that contains the data that you want to replicate (the source cluster), then click the Replication tab.

    The source cluster’s 'Replication' tab showing a 'Setup XDCR' button.
  2. Click Setup XDCR.

    This displays the Setup Replica slide-out menu:

    The 'Add Replica' slide-out menu.
  3. Select a destination cluster.

    Click the Destination Cluster drop-down menu and select the cluster that contains the bucket you want to replicate data to.

    The 'Destination Cluster' drop-down showing a single cluster.
  4. Select source and destination buckets.

    1. Click the Source Bucket drop-down menu and select the source bucket (this is the bucket from which data is to be replicated). Only buckets on the current cluster will be displayed in this menu.

    2. Click the Destination Bucket drop-down menu and select the destination bucket (this is the bucket to which data is to be replicated). Only buckets on the destination cluster will be displayed in this menu.

    Dropdown menus for source and destination buckets.
  5. (Optional) Configure the replication to be bidirectional.

    A bidirectional replication means that the source and target buckets each have a unidirectional replication to each other. Checking the Bidirectional checkbox simply automates the creation of a second replication on the destination cluster that points back to the source cluster (swapping source and destination buckets).

    If you specify filter expressions when creating a bidirectional replication, the filter expressions will be applied to both replications. If you need to have separate filter expressions applied to each direction of a bidirectional replication, then you will need to manually create two separate replications.
  6. (Optional) Add a filter expression.

    A filter expression allows a limited subset of documents to be replicated from the source bucket. A filter expression can be formatted as either a regular expression (regex) or an XDCR filtering expression.

    To add a filter expression:

    1. Enter the expression in the Filter Expression field.

    2. Test the expression against a specified document.

      In the Test Key field, enter the key/ID of a document that you expect to be included by the filter.

      An expression must be tested successfully before it can be included as part of the replication. If an expression is specified without having been tested, the expression is ignored when the replication is saved; and the replication is thus started in unfiltered form.
  7. Once you’re satisfied with the configuration, click Save changes.

    Data will immediately start replicating after you save the replication.

Note that this procedure does not cover allowing an IP. This is because allowing an IP is only required when replicating data to/from a cluster that is located outside of Couchbase Cloud, such as an on-premises cluster. Configuring allowed IPs is not required when replicating data between clusters that are inside Couchbase Cloud.