For Litestream v0.3.x, refer to the previous article.


Install Litestream

1) Check the latest release on GitHub.

2) Pick and install the one that matches your machine architecture.

$ wget https://github.com/benbjohnson/litestream/releases/download/v0.5.5/litestream-0.5.5-linux-arm64.deb
$ sudo dpkg -i litestream-0.5.5-linux-arm64.deb

3) Enable and start the service.

$ sudo systemctl enable litestream
$ sudo systemctl start litestream

4) Check service status.

$ sudo systemctl status litestream

Configure Litestream

1) Locate the configuration file

$ sudo pico /etc/litestream.yml

2) Configure local or S3 replicas based on your needs. Refer to the official guide for more.

access-key-id: AKIAxxxx
secret-access-key: xxxxxx/xxxxxx
region: xxxx
sync-interval: 180s

dbs:
  - path: /path/to/database
    replica:
      url: s3://xxx/yyy

3) Save and restart the service.

$ sudo systemctl restart litestream

Check Backups

1) Snapshots are available in your S3 bucket.


Restore database

1) Install Litestream and copy the config file that contains the AWS S3 credentials.

2) If you lost the original S3 credentials, you can create a new one from the AWS console. Remember to give the necessary S3 permissions.

3) To restore, run the following command.

$ litestream restore -o /path/to/restored_database /path/to/database