How to Set Up Cloud Replication with the Backblaze B2 Command-Line Tool
  • 26 Mar 2026
  • Dark
    Light

How to Set Up Cloud Replication with the Backblaze B2 Command-Line Tool

  • Dark
    Light

Article summary

If you have access to accounts that host both a source bucket and a destination bucket (it can be the same account), you can set up Cloud Replication using the command-line interface (CLI).

Manual Setup

Follow these steps to manually set up Cloud Replication. 

Set Up a Destination Key

$ b2 key create --profile myprofile2 my-bucket-rpldst writeFiles,writeFileLegalHolds,writeFileRetentions,deleteFiles
0024ab2345678900000000234 K001YYABCDE12345678901234567890

Create a B2 CLI Profile for Destination Account

b2 account authorize --profile dest

Set Up a Source Key

$ b2 key create my-bucket-rplsrc readFiles,readFileLegalHolds,readFileRetentions
0014ab1234567890000000123 K001ZA12345678901234567890ABCDE

Set Up Destination Replication

$ b2 bucket update --profile myprofile2 --replication '{
    "asReplicationDestination": {
        "sourceToDestinationKeyMapping": {
            "0014ab1234567890000000123": "0024ab2345678900000000234"
        }
    }
}' my-bucket

Set Up 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


For a record of the changes from previous versions, see the changelog. You can view release history here.

Was this article helpful?