Using LiteFS Cloud for Backups

The simplest way to implement disaster recovery for your LiteFS cluster is to use’s LiteFS Cloud for backups. LiteFS Cloud provides reliable backup and restore functionality, which reduces the risk of data loss in the event that your cluster is lost. You’ll also be able to restore your cluster to any point in time (not just the most recent snapshot), in case you need to revert your state.

In this doc, we’ll show you how to add LiteFS Cloud to an existing LiteFS cluster. If you’re not using LiteFS yet, take a look at the getting started guide, which walks you through setting LiteFS up for your app, including LiteFS Cloud.

If you’d rather implement your own backups, take a look at the Backing up your LiteFS cluster docs.

Creating a LiteFS Cloud cluster

If you want to back up your database using LiteFS Cloud, you’ll need to create a LiteFS Cloud cluster. You can do this in the dashboard. First, sign up for an account if you haven’t already. After you’re signed in, navigate to the LiteFS Cloud section on the left navbar, and then use the Create button to create a new cluster. Here’s a handy link to the LiteFS Cloud dashboard if you prefer!

When you create your LiteFS Cloud cluster, you’ll be asked to save an auth token. Keep this handy - you’ll use it below.

Configuring LiteFS to use LiteFS Cloud

Update LiteFS

Before configuring LiteFS Cloud, you must update your LiteFS to a version that supports LiteFS Cloud. Update to v0.5.0 or greater. You can do this by installing the latest version.

LiteFS Cloud Configuration

When you created your LiteFS Cloud cluster, you got a LiteFS Cloud API authentication token. (If you lost it, you can create a new one in the LiteFS Cloud dashboard.)

This token should be made available to LiteFS via the LITEFS_CLOUD_TOKEN environment variable. If you’re running on, you can add a secret for it with:

fly secrets set LITEFS_CLOUD_TOKEN="litefs cloud auth token from dashboard"

Previous non-cloud litefs databases will automatically be synched to the litefs cloud cluster.

If you’re not running on, you need to set the LITEFS_CLOUD_TOKEN environment variable, and then restart LiteFS on each node. How you do this depends on how you have configured LiteFS. If you’re running LiteFS separately from your app, then for each node, you should:

  • Update your configuration with the new environment variable
  • Stop your app (so that it’s not reading/writing data anymore)
  • Restart litefs
  • Start your app again!

If you’re running LiteFS via systemd, you can restart it with:

systemctl restart litefs

Remember that this needs to be run for every LiteFS node.