Set Up Cloud Replication with the CLI
    • Dark
      Light

    Set Up Cloud Replication with the CLI

    • 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). Backblaze B2 Cloud Storage recommends that you use the automatic Replication Setup command. Otherwise, use the manual setup procedure.

    Automatic Setup

    $ b2 replication setup --destination-profile myprofile2 my-bucket my-bucket2

    Optionally, you can choose the source rule priority and the source rule name using the Replication Setup command.

    Note
    The Replication Setup command reuses or provisions a source key with no prefix and full reading capabilities and a destination key with no prefix and full writing capabilities.

    Manual Setup

    Follow these steps to manually set up Cloud Replication

    Set Up a Source Key

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

    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

    Set Up a Destination Key

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

    Set Up Destination Replication

    $ b2 bucket update --profile myprofile2 --replication '{
        "asReplicationDestination": {
            "sourceToDestinationKeyMapping": {
                "0014ab1234567890000000123": "0024ab2345678900000000234"
            }
        }
    }' my-bucket
    For a record of the changes from previous versions, see the changelog. You can view release history here.

    Was this article helpful?