Put Bucket Replication

Last updated:2021-04-28 11:04:15

Description

You can call this operation to configure a cross-region replication rule for a source bucket. You can configure only one cross-region replication rule for each source bucket. If a cross-region replication rule has been configured for a source bucket, the system will prompt you when you attempt to configure another rule for the bucket. After you configure a rule, KS3 automatically adds matched objects to the destination bucket.

Permission

To call this operation, you must have the PUTBucketReplication permission on the bucket.

Request

Request syntax

PUT /?crr HTTP/1.1  
Host: {BucketName}.{endpoint}  
Date: {date}  
Authorization: {SignatureValue}  
Content-length: {length}  
Content-MD5: {md5}   

<Replication xmlns="http://s3.amazonaws.com/doc/2006-03-01/">  
	<prefix>prefix1</prefix>  
	<prefix>prefix2</prefix>  
	<DeleteMarkerStatus>Enabled</DeleteMarkerStatus>  
	<targetBucket>bucketname</targetBucket>
</Replication>

Request parameters

This operation does not involve request parameters.

Request headers

Parameter Description Required
Content-MD5 The 128-bit MD5 digest of data that is Base64-encoded. You must include the Content-MD5 header in this operation to verify that the request body is not corrupted. For more information, see RFC-1864.
Type: String
Default value: none
Yes

Request body

The request body describes the cross-region replication configuration and is in XML format.

<Replication xmlns="http://s3.amazonaws.com/doc/2006-03-01/">  
	<prefix>prefix1</prefix>  
	<prefix>prefix2</prefix>  
	<DeleteMarkerStatus>Enabled</DeleteMarkerStatus>  
	<targetBucket>bucketname</targetBucket>
</Replication>

The following table describes the parameters in the request body.

Parameter Description Required
Replication The container of the cross-region replication rule. You can configure only one rule for one source bucket.
Type: Container
Child node: none
Parent node: none
Yes
prefix The prefix for matching objects. Only the objects matching the prefix are replicated. You can add up to five prefixes for a cross-region replication rule, and the prefixes must be unique.
Type: String
Parent node: Replication
No
DeleteMarkerStatus Specifies whether to enable deletion replication. If this parameter is set to Enabled, deletion replication is enabled. When an object is deleted from the source bucket, the object replica in the destination bucket is also deleted. If this parameter is set to Disabled or is unspecified, deletion replication is disabled.
Type: String
Parent node: Replication
No
targetBucket The destination bucket for cross-region replication.
Type: String
Parent node: Replication
Yes

Notes:

  • You can configure only one cross-region replication rule for each source bucket. However, KS3 supports two-way replication, that is, a source bucket can also serve as a destination bucket of its destination bucket.

  • Before enabling cross-region replication for a bucket, make sure that no replication is enabled between the bucket and other buckets. For example, if you have enabled replication from Bucket A to Bucket B, you cannot enable replication from Bucket A to Bucket C unless you disable the replication from Bucket A to Bucket B. Similarly, if replication from Bucket A to Bucket B is enabled, you cannot enable replication from Bucket C to Bucket B.

  • You can add up to five prefixes for a cross-region replication rule, and the prefixes must be unique.

  • Objects in the destination bucket are the exact replicas of those in the source bucket. They have the same object names, metadata, and content as the source objects, such as the same creation time, owner, storage class, user-defined metadata, object ACL, object content, and object encryption method (using a KS3-managed key). Therefore, any changes of the preceding data are synchronized to the destination bucket.

  • Objects replicated to the destination bucket conform to the lifecycle rule of the destination bucket.

  • Before deleting a bucket with replication enabled, you must disable replication.

  • The priority of cross-region replication is higher than that of lifecycle management. An object is replicated to the destination bucket before the lifecycle management operation is performed on the object, to comply with the principle of data security preceding data management.

  • The following objects and data are not replicated:

    • Data encrypted by the client.
    • New data in the source bucket that is replicated from other buckets.
    • Bucket configuration updates, which do not affect the objects in the bucket.
    • Archive objects, unless the object content changes.

Response

Response headers

This operation involves only common response headers. For more information, see Public Response Header.

Response body

No response body is returned.

Operation-specific errors

Error code Description HTTP status code
NoSuchBucketReplicationConfiguration No cross-region replication rule is configured for the bucket. 404 Not Found
Invalid Argument A cross-region replication rule has been configured for the bucket.
The request body is in an invalid format.
The number of prefixes exceeds five.
The length of the prefix exceeds the limit.
The prefix contains special characters.
400 Invalid Argument

Examples

Sample request

PUT /?crr HTTP/1.1
Host: ks3-example.ks3-cn-beijing.ksyun.com
Date: Wed, 14 May 2014 02:11:21 GMT
Content-MD5: xxx 
Authorization: authorization string
Content-Length: yyy
Content-type: application/xml

<Replication>
    <prefix>abc</prefix>
    <prefix>xyz</prefix>
    <DeleteMarkerStatus>Enabled</DeleteMarkerStatus>
    <targetBucket>targetbucket</targetBucket>
</Replication>

In this example, a cross-region replication rule is configured for a bucket, two prefixes abc and xyz are configured for the cross-region replication rule, deletion replication is enabled, and the destination bucket is targetbucket.

Sample response

HTTP/1.1 200 OK
Content-Length: 0
Date: Tue, 19 Jul 2017 09:14:23 GMT
Server: Tengine
x-kss-request-id: 6af24440694b4d00b8de063ccbe86336
​```xxxxxxxxxx HTTP/1.1 200 OKContent-Length: 0Date: Tue, 19 Jul 2017 09:14:23 GMTServer: Tenginex-kss-request-id: 6af24440694b4d00b8de063ccbe86336

Did you find the above information helpful?

Unhelpful
Mostly Unhelpful
A little helpful
Helpful
Very helpful

What might be the problems?

Insufficient
Outdated
Unclear or awkward
Redundant or clumsy
Lack of context for the complex system or functionality

More suggestions

0/200

Please give us your feedback.

Submitted

Thank you for your feedback.

问题反馈