Data Synchronization Configuration
Updated at:2025-11-03
Bucket data synchronization configuration
Set data synchronization rules
-
Basic workflow
- Create a BosClient instance.
- Call the putBucketReplication() method.
-
Example code
JavaScript1const ReplicationInfo = { 2 status:"enabled", 3 resource:[ 4 bucketName + "/*" 5 ], 6 destination: 7 { 8 bucket: <dstBucketName>, 9 storageClass: "COLD" 10 }, 11 replicateHistory: 12 { 13 bucket: <dstBucketName>, 14 storageClass:"COLD" 15 }, 16 replicateDeletes:"enabled", 17 id: <ruleId> 18} 19client.putBucketReplication(<BucketName>,<ReplicationInfo>) 20 .then(function(response) { 21 if(response) { 22 // TODO 23 } 24 }) 25 .catch(function() {}); - Parameter: ReplicationInfo structure
| Parameters | Required or not | Description |
|---|---|---|
| id | Yes | Rule name of replication. The ID must consist of numbers, letters, hyphens (-), and underscores (_), and shall not exceed 20 characters. |
| status | Yes | Is it effective |
| resource | Yes | Effective prefix of replication. The resource configuration format is {$BucketName/$BucketName+/. |
| destination | Yes | Destination location configuration of replication |
| +bucket | Yes | Destination Bucket name |
| +storageClass | No | Storage class of destination object. If the storage class is to be consistent with that of the source Bucket, this parameter does not need to be configured; if you need to specify a separate storage class, it can be STANDARD, STANDARD_IA and COLD; if it is a multi-AZ type bucket, the available values are MAZ_STANDARD_IA and MAZ_STANDARD. |
| replicateHistory | No | Historical file replication: When enabled, all existing objects will be synchronously replicated to the destination bucket, sharing the same resource scope. |
| +storageClass | No | Storage class of destination object. If the storage class is to be consistent with that of the source Bucket, this parameter does not need to be configured; if you need to specify a separate storage class, it can be STANDARD, STANDARD_IA and COLD; if it is a multi-AZ type bucket, the available values are MAZ_STANDARD_IA and MAZ_STANDARD. |
| replicateDeletes | Yes | It indicates whether Delete synchronization function is enabled. It is enabled,disabled. |
Note:
- The user must own the source bucket with FULL_CONTROL permission and have write access to the target bucket.
- Both the source bucket and the target bucket must exist.
- The source bucket and target bucket can be in the same region or different regions.
- The target bucket and source bucket can be under the same account or different accounts, but the source account must have the write permission for the destination bucket.
- The total configuration size must not exceed 128 KB, and the combined length of all rules under the current bucket must not exceed 200 KB.
- Data synchronization does not currently support archive storage class files; such files will be ignored during the synchronization process.
- Users can configure up to 10 replication rules.
- A single rule can include up to 20 resources.
- The ID must consist of numbers, letters, hyphens (-), and underscores (_), and shall not exceed 20 characters
Get specified data synchronization rules
With this method, users can retrieve data synchronization information for a specified bucket ID, including the source bucket name, destination bucket name, storage class, whether historical replication is performed, data synchronization policy, destination region, etc.
- Basic workflow
Plain Text
11. Create a BosClient instance.
22. Call the getBucketReplication() method.
- Code example
JavaScript
1 client.getBucketReplication(<BucketName>,<RuleId>)
2.then(function(response) {
3 if(response) {
4 // TODO
5 }
6 else {}
7})
8.catch(function() {});
9 ```
10
11
12**Delete specified data synchronization rule**
13
14Users can delete the data synchronization rule with the specified ID of the bucket through this method
15
16- Basic workflow
17
18 1. Create a BosClient instance.
19 2. Call the deleteBucketReplication() method.
20
21- Code example
22```js
23 client.deleteBucketReplication(<BucketName>,<RuleId>)
24.then(function(response) {
25 if(response) {
26 // TODO
27 }
28 else {}
29})
30.catch(function() {});
31 ```
32
33** List all data synchronization rules **
34
35Users can get all replication synchronization rules of the bucket through this method
36- Basic workflow
37
38 1. Create a BosClient instance.
39 2. Call the listBucketReplication() method.
40
41- Code example
42```js
43 client.listBucketReplication(<BucketName>)
44.then(function(response) {
45 if(response) {
46 // TODO
47 }
48 else {}
49})
50.catch(function() {});
51 ```
52
53
54
55** Get the process status of specified data synchronization rules **
56
57Users can get the progress status of data synchronization replication with the specified ID of the bucket through this method
58- Basic workflow
59
60 1. Create a BosClient instance.
61 2. Call the getBucketReplicationProgress() method.
62
63- Code example
64```js
65 client.getBucketReplicationProgress(<BucketName>,<RuleId>)
66.then(function(response) {
67 if(response) {
68 // TODO
69 }
70 else {}
71})
72.catch(function() {});
73 ```
