Configuring Cross-Region Replication for a Bucket

Functions

Cross-region replication refers to the automatic and asynchronous replication of objects across buckets in different regions. By activating cross-region replication, OBS can copy new objects and modified objects from a source bucket in one region to a destination bucket in a different region.

The following two requirements must be met when configuring the cross-region replication for a bucket:

  1. Cross-region replication can be configured only when the versioning statuses of the source and destination buckets are the same. For details about how to configure bucket versioning, see Configuring Versioning for a Bucket.

  2. The owner and agency (OBS) of the source bucket must have the permission to write the destination bucket (configured with BucketPolicy), and the agency (OBS) must have the read permission for the source bucket. This permission delegation needs to be implemented by calling the BucketPolicy API.

For details about how to configure the bucket policy, see Configuring a Bucket Policy. After the bucket policy is set, the agency (OBS) can read objects from the source bucket and copy objects to the destination bucket.

Request Syntax

PUT /?replication HTTP/1.1
Host: bucketname.obs.region.example.com
x-obs-date: date
Content-MD5: MD5
Authorization: authorization string
Content-Length: contentlength

<ReplicationConfiguration>
    <Agency>testAcy</Agency>
    <Rule>
        <ID>rule1</ID>
        <Prefix>key-prefix</Prefix>
        <Status>rule-status</Status>
        <Destination>
            <Bucket>targetbucketname</Bucket>
            <StorageClass>STANDARD</StorageClass>
            <DeleteData>Enabled</DeleteData>
        </Destination>
        <HistoricalObjectReplication>Enabled</HistoricalObjectReplication>
    </Rule>
</ReplicationConfiguration>

Request Parameters

This request contains no message parameters.

Request Headers

The request uses one header, as described in the following table.

Table 1 Request header for cross-region replication

Element

Description

Mandatory

Content-MD5

Base64-encoded 128-bit MD5 digest of the message according to RFC 1864.

Yes

Request Elements

This request contains elements to specify the replication configuration for the bucket in XML format. The following table lists request elements:

Table 2 Bucket replication configuration elements

Element

Description

Mandatory

ReplicationConfiguration

Container for the replication rules. A maximum of 100 rules can be configured. The size of the XML file can reach 50 KB.

Type: container

Children: Rule

Ancestor: none

Yes

Agency

Name of the agency, which can have a maximum of 64 characters.

Type: string

Ancestor: ReplicationConfiguration

Yes

Rule

Container of a specified replication rule.

The replication configuration must contain at least one rule. The maximum number of rules is 100.

Type: container

Ancestor:

ReplicationConfiguration

Yes

ID

Unique identifier of a rule, with a maximum length of 255 characters.

Type: string

Ancestor: Rule

No

Status

If the value of this element is Disabled, this rule will be ignored.

Type: string

Ancestor: Rule

Value options: Enabled, Disabled

Yes

Prefix

Prefix of an object key name, applicable to one or more objects. If the Prefix is left blank, the cross-region replication rule is applied to the whole bucket.

The maximum length of a prefix is 1024 characters. Duplicated prefixes are not supported.

Type: string

Ancestor: Rule

Yes

Destination

Container for the destination bucket information.

Type: container

Ancestor: Rule

Yes

Bucket

Bucket used to store object copies that are marked by rules.

If the replication configuration contains multiple rules, the rules must specify the same bucket as the destination bucket.

Type: string

Ancestor: Destination

Yes

StorageClass

Storage class of an object

Type: string

Ancestor: Destination

Value options: STANDARD, WARM, COLD

No

DeleteData

Keyword for synchronizing object deletion operations. If the value is Enabled, the object deletion for the source bucket will be replicated to the destination bucket.

Type: string

Ancestor: Destination

Value options: Enabled and Disabled (If this element is absent from the request, Disabled is applied by default.)

No

HistoricalObjectReplication

Keyword for copying a historical object. If the value is Enabled, historical objects meeting this rule are copied.

Type: string

Ancestor: Rule

Value options: Enabled and Disabled (If this element is absent from the request, Disabled is applied by default.)

No

Response Syntax

HTTP/1.1 status_code
Server: OBS
Date:date
Content-Length: contentlength

Response Headers

The response to the request uses common headers. For details, see Table 1.

Response Elements

This response contains no elements.

Error Responses

No special error responses are returned for this request.

Sample Request

PUT /?replication HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.example.com
Accept: */*
Date: Wed, 27 Jun 2018 13:39:15 +0000
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:CdeqU0Vg9xNdJMZ0PGPgh5EnkO0=
Content-MD5: l/Z8mfSX+VyV8k5EhIQz5Q==
Content-Length: 330

<ReplicationConfiguration>
   <Agency>testAcy</Agency>
   <Rule>
       <ID>Rule-1</ID>
       <Status>Enabled</Status>
       <Prefix></Prefix>
       <Destination>
          <Bucket>dstbucket</Bucket>
          <StorageClass>STANDARD</StorageClass>
          <DeleteData>Enabled</DeleteData>
       </Destination>
       <HistoricalObjectReplication>Enabled</HistoricalObjectReplication>
     </Rule>
</ReplicationConfiguration>

Sample Response

HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: B59500000164417839932E5A2295674C
x-obs-id-2: 32AAAQAAEAABKAAQAAEAABAAAQAAEAABCStv51t2NMMx+Ou+ow7IWV4Sxo231fKe
Date: Wed, 27 Jun 2018 13:39:15 GMT
Content-Length: 0