DEV Community

Cover image for Remember to set the frequency for replication to Litestream!
Lucian Ghinda
Lucian Ghinda

Posted on • Originally published at notes.ghinda.com

Remember to set the frequency for replication to Litestream!

Curious about how I ended up with an invoice nearing $100 for conducting over 20 million Class A operations on Cloudflare R2?

I initiated several Litestream processes across a variety of side projects and forgot to set the sync interval! :) It defaults to 1s

The backup I was handling was more complex than the main production database. It included slight variations in the SQLite file because it automatically queried various external services to check the status of different entities.

Just add:

sync-interval: 4h
Enter fullscreen mode Exit fullscreen mode

to the replica section.

Here is a full example:

dbs:
  - path: /mnt/goodenoughtesting/current/storage/production.sqlite3
    replicas:
      - type: s3
        bucket: $GOOD_ENOUGH_TESTING_BACKUP
        path: production
        access-key-id: $LITESTREAM_ACCESS_KEY_ID
        secret-access-key: $LITESTREAM_SECRET_ACCESS_KEY
        endpoint: $LITESTREAM_REPLICA_ENDPOINT
        region: auto
        sync-interval: 4h
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.