You can use data replication features to automatically synchronize objects and the operations performed on the objects, such as the creation, overwriting, and deletion of objects from a source bucket to a destination bucket. OSS provides two data replication features: cross-region replication (CRR) and same-region replication (SRR).
Notes
The sample code in this topic uses the region ID
cn-hangzhou
of the China (Hangzhou) region. By default, the public endpoint is used to access resources in a bucket. If you want to access resources in the bucket by using other Alibaba Cloud services in the same region in which the bucket is located, use an internal endpoint. For more information about the regions and endpoints supported by Object Storage Service (OSS), see OSS regions and endpoints.In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials.
By default, an Alibaba Cloud account is granted data replication-related permissions. If you want to replicate data as a RAM user or by using temporary access credentials provided by Security Token Service (STS), you must have the required permissions. For example:
The
oss:PutBucketReplication
permission is required for enabling data replication.The
oss:PutBucketRtc
permission is required for enabling and disabling the replication time control (RTC) feature.The
oss:GetBucketReplication
permission is required for querying data replication rules.The
oss:GetBucketReplicationLocation
permission is required for querying available destination regions.The
oss:GetBucketReplicationProgress
permission is required for querying the progress of a data replication task.The
oss:DeleteBucketReplication
permission is required for disabling data replication.
Sample code
References
For more information about the API operation that you can call to enable data replication, see PutBucketReplication.
For more information about the API operation for enabling or disabling the RTC feature for existing CRR rules, see PutBucketRTC.
For more information about the API operation for querying data replication rules, see GetBucketReplication.
For more information about the API operation for querying regions to which data can be replicated, see GetBucketReplicationLocation.
For more information about the API operation for querying the progress of a data replication task, see GetBucketReplicationProgress.
For more information about the API operation for disabling data replication, see DeleteBucketReplication.