Periodic backup via export
The simplest approach is to export your database via the litefs export command and then upload that file to long-term storage such as S3. Theexport command is safe to use on a live database
and can even be run remotely by specifying the -url flag.
Once the database is downloaded, it can be compressed & uploaded to S3.
Continuous backup via Litestream
Litestream is a tool for continuously streaming incremental backups to S3-compatible object storage. You can use it on top of LiteFS to provide point-in-time recovery in case your cluster fails for any reason.Initialize your bucket
First, you’ll need to create a bucket on S3-compatible storage. In this example, we’ll use Tigris since it integrates nicely with Fly.io.Set up your configuration file
Once your bucket is created, you’ll need to create a Litestream configuration file. In this example, changemy.db and mybucket to your respective database file and
bucket names:
/etc/litestream.yml then Litestream will pick it up
automatically for any Litestream commands you use.
The meta-path should be a path on a persistent volume. In this example, we’re
assuming that /var/lib/litefs has been mounted from a volume.
Running Litestream
Litestream should be run after LiteFS has been initialized so we can specify it in the LiteFSexec. Litestream can run its own exec so you should specify
your application there.