Inter-Sync Gateway Replication Configuration

      +

      Using Sync Gateway’s Admin REST API to configure and manage inter-Sync Gateway replications

      Pre-3.0 Legacy Configuration Equivalents

      This content describes configuration for Sync Gateway 3.0 and higher — for legacy configuration, see: Legacy Pre-3.0 Configuration

      Introduction

      Sync Gateway 3.0 and later uses the Admin REST API to provision persistent configuration changes. This page introduces the Add or Update a Replication endpoint for convenience — see Replication for a full description of the endpoints available.

      Using CA Certificates

      Required CA certificates must be added to the system certificate pool.

      On Linux, this is done using one of the following methods:

      • Adding the location of the certificate to SSL_CERT_FILE environment variable,

      • Placing the certificate in a location pointed to by the SSL_CERT_DIR environment variable.

      • Using one of the system-dependent locations listed in this file.

      For Windows-based systems, add CA certificate files to the system root certificate store.

      Upsert a replication

      PUT /{db}/_replication/{replicationid}

      Description

      Create or update a replication in the database.

      The replication ID does not need to be set in the request body.

      If an existing replication is being updated, that replication must be stopped first and, if the replication_id is specified in the request body, it must match the replication ID in the URI.

      Required Sync Gateway RBAC roles:

      • Sync Gateway Replicator
      Consumes
      • application/json

      Produces
      • application/json

      Parameters

      Path Parameters

      Name Description Schema

      db
      required

      The name of the database to run the operation against.

      String

      replicationid
      required

      What replication to target based on its replication ID.

      String

      Body Parameter

      Name Description Schema

      Body
      optional

      If the replication_id matches an existing replication then the existing configuration will be updated. Only the specified fields in the request will be used to update the existing configuration. Unspecified fields will remain untouched.

      Responses

      HTTP Code Description Schema

      200

      Updated existing configuration successfully

      201

      Created new replication successfully

      400

      There was a problem with your request

      404

      Resource could not be found

      Example

      • Curl

      • HTTP

      curl --location --request PUT 'http://localhost:4985/db1-local/_replication/db1-rep-id1 '\
      --header 'Content-Type: application/json' \
      --data-raw '{
        "direction": "push",
        "purge_on_removal": false,
        "remote": "http://user1:password1@example.com:4984/db1-remote",
        "filter":"sync_gateway/bychannel",
        "query_params": {
          "channels":["channel.user1"]
        },
        "continuous": false
        }'
      PUT /db1-local/_replication/db1-rep-id1 HTTP/1.1
      Host: localhost:4985
      Content-Type: application/json
      Content-Length: 235
      
      {"direction": "push",
        "purge_on_removal":false,
        "remote": "http://user1:password1@example.com:4984/db1-remote",
        "filter":"sync_gateway/bychannel",
        "query_params": {
          "channels":["channel.user1"]
        },
        "continuous": false
      }

      Schema

      This section shows Sync Gateway’s replication configuration settings in schema format for convenience in constructing JSON models for use in the Admin REST API.

      The configuration settings described here are provisioned through the Replication endpoints.

      ERROR (template-block): Data file attachment$bundled-admin.yaml not resolved

      Errors

      This section shows possible error responses returned by the Admin REST API.

      Property Schema

      error
      required

      The error name.

      String

      reason
      required

      The error description.

      String