Replicating to Azure Blob Storage

This guide will show you how to use Litestream to replicate to an Azure Blob Storage container. You will need an Azure account and to complete this guide.


Create a container

In the Azure Portal, use the top search bar to navigate to “Storage Accounts”. If you do not have a storage account, click the “New” button, enter your storage account name, and click “Review + create”.

Once you have a storage account, select it from the list of accounts and navigate to the Containers subsection. Click the "+" button to create a new container. Remember your storage account name and your container name as you’ll need those later.

Create an access key

From your storage account, navigate to the Access Keys subsection. You’ll see two access keys already exist. Click the “Show keys” button to reveal them. Copy the value of one of the “Key” textboxes. This will be be your account key.


Command line usage

You can replicate to Azure Blob Storage from the command line by setting your account key via an environment variable:


You can then specify your replica as a replica URL on the command line. For example, you can replicate a database to your container with the following command. Replace the placeholders for your account, container, & path.

litestream replicate /path/to/db abs://STORAGEACCOUNT@CONTAINERNAME/PATH

You can later restore your database from Azure Blob Storage to a local my.db path with the following command.

litestream restore -o my.db abs://STORAGEACCOUNT@CONTAINERNAME/PATH

Configuration file usage

Litestream is typically run as a background service which uses a configuration file. You can configure a replica for your database using the url format.

  - path: /path/to/local/db
        account-key:  ACCOUNTKEY

Or you can expand your configuration into multiple fields:

  - path: /path/to/local/db
      - type: abs
        account-name: STORAGEACCOUNT
        account-key:  ACCOUNTKEY
        bucket:       CONTAINERNAME
        path:         PATH

You can also use the LITESTREAM_AZURE_ACCOUNT_KEY environment variable instead of specifying the account key in your configuration file.