Replicating to Backblaze B2
This guide will show you how to use Backblaze B2 as a database replica path for Litestream.
Create a bucket
To begin, you’ll need a bucket to store your data. If you don’t already have one set up in Backblaze, follow the steps below:
- From your Backblaze dashboard, go to My Account > Buckets
- Click “Create a Bucket”
- Enter a unique name for “Bucket Unique Name” and leave the remaining fields as their defaults.
- Click “Create a Bucket”
- Copy the bucket details to the appropriate places in your
litestream.yml
file:
You may want to change Lifecycle Settings to “Keep only the last version of the file” as Litestream files are immutable and don’t require versioning.
dbs:
- path: path-to-your-local-db-file
replicas:
- type: s3
bucket: your-bucket-name
path: db # change to whatever path you want
endpoint: s3.us-west-000.backblazeb2.com # change this
force-path-style: true
Create a user
Next, create a user with programmatic access to the bucket you just created.
- From your Backblaze dashboard, go to My Account > App Keys
- Click “Add Application Key”
- In “Name of Key”, enter any unique name
- Under “Allow access to Bucket(s)” select the bucket you created above.
- Leave the remaining fields as their defaults.
- Click “Create new key”
- Copy the credentials to the appropriate places in your
litestream.yml
file- The
keyID
field is youraccess-key-id
- The
applicationKey
field is yoursecret-access-key
- The
access-key-id: your-backblaze-keyID
secret-access-key: your-backblaze-applicationKey
Configuration file
Your final litestream.yml
configuration file should look like this:
access-key-id: your-backblaze-keyID
secret-access-key: your-backblaze-applicationKey
dbs:
- path: path-to-your-local-db-file
replicas:
- type: s3
bucket: your-bucket-name
path: db # change to whatever path you want
endpoint: s3.us-west-000.backblazeb2.com # change this
force-path-style: true