If you cannot use the automatic setup, you must manually configure the source key, the source bucket replication rules, the destination key, and the destination bucket mapping. Follow these steps in order:
1. Create the Source Key
Create a key for the source bucket with the following permissions: readFiles, readFileLegalHolds, and readFileRetentions.
2. Configure Source Replication Rules
Update the source bucket using b2 bucket update --replication with a JSON object defining asReplicationSource. This includes replicationRules (specifying destinationBucketId, fileNamePrefix, includeExistingFiles, isEnabled, priority, and replicationRuleName) and the sourceApplicationKeyId.
3. Create the Destination Key
Create a key for the destination bucket using a specific profile (e.g., --profile myprofile2) with the following permissions: writeFiles, writeFileLegalHolds, writeFileRetentions, and deleteFiles.
4. Configure Destination Replication Mapping
Update the destination bucket using b2 bucket update --replication with a JSON object defining asReplicationDestination. This must include a sourceToDestinationKeyMapping that maps the sourceApplicationKeyId to the new destination key ID.
# 1. Create source key
$ b2 key create my-bucket-rplsrc readFiles,readFileLegalHolds,readFileRetentions
# 2. Setup source replication
$ b2 bucket update --replication '{ "asReplicationSource": { "replicationRules": [ { "destinationBucketId": "85644d98debc657d880b0e1e", "fileNamePrefix": "files-to-share/", "includeExistingFiles": false, "isEnabled": true, "priority": 128, "replicationRuleName": "my-replication-rule-name" } ], "sourceApplicationKeyId": "0014ab1234567890000000123" } }' my-bucket
# 3. Create destination key
$ b2 key create --profile myprofile2 my-bucket-rpldst writeFiles,writeFileLegalHolds,writeFileRetentions,deleteFiles
# 4. Setup destination replication
$ b2 bucket update --profile myprofile2 --replication '{ "asReplicationDestination": { "sourceToDestinationKeyMapping": { "0014ab1234567890000000123": "0024ab2345678900000000234" } } }' my-bucket