Help Center/ Object Storage Service/ API Reference/ APIs/ Advanced Bucket Settings/ Configuring Cross-Region Replication for a Bucket
Updated on 2025-08-22 GMT+08:00

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.

An IAM agency is required for configuring cross-region replication. For details, see Creating an Agency for Cross-Region Replication.

To configure cross-region replication for a bucket, the following two requirements must be met:

  1. The versioning statuses of the source and destination buckets are the same. For details, see Configuring Versioning for a Bucket.
  2. The source bucket's owner and agency (OBS) have the write permission for the destination bucket (with a bucket policy configured), and the agency (OBS) also has the read permission for the source bucket. This permission delegation needs to be implemented by using a bucket policy.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
PUT /?replication HTTP/1.1 
Host: bucketname.obs.region.myhuaweicloud.com 
x-obs-date: date 
Content-SHA256: SHA256
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

Parameter

Mandatory (Yes/No)

Type

Description

Content-SHA256

Yes

string

Definition:

SHA-256 digest string of the message body, that is, the string obtained after the 256-bit SHA-256 value of the message body is encoded using Base64

Range:

None

Default value:

None

Request Elements

The request body 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

Parameter

Mandatory (Yes/No)

Type

Description

ReplicationConfiguration

Yes

Container

Definition:

Container of cross-region replication rules. ReplicationConfiguration is the parent node of Rule and Agency.

Constraints:

  • A bucket can have 1 to 100 cross-region replication rules.
  • The size of the request body for configuring a cross-region replication rule at a time cannot exceed 50 KB.

Range:

None

Default value:

None

Rule

Yes

Container

Definition:

Container of a specified cross-region replication rule.

Constraints:

A bucket can have 1 to 100 cross-region replication rules.

Range:

For details, see Table 3.

Default value:

None

Agency

Yes

String

Definition:

Name of the agency created by the user for cross-region replication.

Constraints:

None

Range:

The value is a string of 0 to 64 characters.

Default value:

None

Table 3 Rule parameter description

Parameter

Mandatory (Yes/No)

Type

Description

ID

No

String

Definition:

ID of the cross-region replication rule.

Constraints:

The rule ID must be unique.

Range:

The value is a string of 0 to 255 characters.

Default value:

None

Status

Yes

String

Definition:

Whether to enable the cross-region replication rule.

Constraints:

None

Range:

  • Enabled: The rule is enabled.
  • Disabled: The rule is disabled.

Default value:

None

Prefix

Yes

String

Definition:

The prefix of an object name, applicable to one or more objects.

Constraints:

  • If the Prefix is left blank, the cross-region replication rule is applied to the whole bucket.
  • The prefix characters between rules cannot overlap. For example, two rules are configured, the prefix of rule 1 is object, and the prefix of rule 2 is obj. Both prefixes contain obj.

Range:

The value is a UTF-8 string of 1 to 1024 characters.

Default value:

None

Destination

Yes

Container

Definition:

Container for the destination bucket information.

Constraints:

None

Range:

For details, see Table 4.

Default value:

None

HistoricalObjectReplication

No

String

Definition:

Whether to replicate historical objects that meet the cross-region replication rule.

Constraints:

None

Range:

  • Enabled: Replicate historical objects that meet the cross-region replication rule.
  • Disabled: Historical objects that meet the cross-region replication rule are not replicated.

Default value:

If this parameter is not set, Disabled is used by default.

Table 4 Destination parameters

Parameter

Mandatory (Yes/No)

Type

Description

Bucket

Yes

String

Definition:

Name of the destination bucket for cross-region replication. The bucket is used to store object copies identified by the cross-region replication rule.

Constraints:

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

Range:

The value can contain 3 to 63 characters.

Default value:

None

StorageClass

No

String

Definition:

The storage class to which objects replicated to the destination bucket will be changed.

Constraints:

None

Range:

  • STANDARD: Standard storage
  • WARM: Infrequent Access storage
  • COLD: Archive storage
  • DEEP_ARCHIVE: Deep Archive storage (limited OBT)

Default value:

None

DeleteData

No

String

Definition:

Whether to synchronously delete objects with the same names in the destination bucket through cross-region replication after the objects in the source bucket are deleted.

Constraints:

None

Range:

  • Enabled: The deletion of objects in the source bucket will be synchronized to the destination bucket.
  • Disabled: The deletion of objects in the source bucket will not be synchronized to the destination bucket.

Default value:

If this parameter is not set, Disabled is used by default.

Response Syntax

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
PUT /?replication HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Accept: */*
Date: Wed, 27 Jun 2018 13:39:15 +0000
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:CdeqU0Vg9xNdJMZ0PGPgh5EnkO0=
Content-SHA256: ogX9qClMrVJUBiUSIKDFM0qO41jJM0I5SCN55/OtMyI=
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

1
2
3
4
5
6
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