{"id":13878023,"url":"https://github.com/fractaledmind/litestream-ruby","last_synced_at":"2025-05-15T11:07:50.769Z","repository":{"id":211874832,"uuid":"730167548","full_name":"fractaledmind/litestream-ruby","owner":"fractaledmind","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-10T20:20:35.000Z","size":363,"stargazers_count":198,"open_issues_count":17,"forks_count":23,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-14T19:58:49.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fractaledmind.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-11T10:51:34.000Z","updated_at":"2025-04-10T20:20:40.000Z","dependencies_parsed_at":"2023-12-24T07:44:16.323Z","dependency_job_id":"be8419bc-2f72-4c1d-9d7a-1848c8425b0d","html_url":"https://github.com/fractaledmind/litestream-ruby","commit_stats":{"total_commits":202,"total_committers":11,"mean_commits":"18.363636363636363","dds":0.07425742574257421,"last_synced_commit":"f32a1bfa1da89ed6334034c5ad05393fd28cc7b2"},"previous_names":["fractaledmind/litestream-ruby"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Flitestream-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Flitestream-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Flitestream-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fractaledmind%2Flitestream-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fractaledmind","download_url":"https://codeload.github.com/fractaledmind/litestream-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328384,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:37.803Z","updated_at":"2025-05-15T11:07:50.715Z","avatar_url":"https://github.com/fractaledmind.png","language":"Ruby","funding_links":["https://github.com/sponsors/fractaledmind"],"categories":["Ruby"],"sub_categories":[],"readme":"# litestream-ruby\n\n\u003cp\u003e\n  \u003ca href=\"https://rubygems.org/gems/litestream\"\u003e\n  \u003cimg alt=\"GEM Version\" src=\"https://img.shields.io/gem/v/litestream?color=168AFE\u0026include_prereleases\u0026logo=ruby\u0026logoColor=FE1616\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://rubygems.org/gems/litestream\"\u003e\n    \u003cimg alt=\"GEM Downloads\" src=\"https://img.shields.io/gem/dt/litestream?color=168AFE\u0026logo=ruby\u0026logoColor=FE1616\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/testdouble/standard\"\u003e\n    \u003cimg alt=\"Ruby Style\" src=\"https://img.shields.io/badge/style-standard-168AFE?logo=ruby\u0026logoColor=FE1616\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/fractaledmind/litestream-ruby/actions/workflows/main.yml\"\u003e\n    \u003cimg alt=\"Tests\" src=\"https://github.com/fractaledmind/litestream-ruby/actions/workflows/main.yml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/sponsors/fractaledmind\"\u003e\n    \u003cimg alt=\"Sponsors\" src=\"https://img.shields.io/github/sponsors/fractaledmind?color=eb4aaa\u0026logo=GitHub%20Sponsors\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://ruby.social/@fractaledmind\"\u003e\n    \u003cimg alt=\"Ruby.Social Follow\" src=\"https://img.shields.io/mastodon/follow/109291299520066427?domain=https%3A%2F%2Fruby.social\u0026label=%40fractaledmind\u0026style=social\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/fractaledmind\"\u003e\n    \u003cimg alt=\"Twitter Follow\" src=\"https://img.shields.io/twitter/url?label=%40fractaledmind\u0026style=social\u0026url=https%3A%2F%2Ftwitter.com%2Ffractaledmind\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n[Litestream](https://litestream.io/) is a standalone streaming replication tool for SQLite. This gem provides a Ruby interface to Litestream.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```sh\nbundle add litestream\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n```sh\ngem install litestream\n```\n\nAfter installing the gem, run the installer:\n\n```sh\nrails generate litestream:install\n```\n\nThe installer will create a configuration file at `config/litestream.yml` and an initializer file for configuring the gem at `config/initializers/litestream.rb`.\n\nThis gem wraps the standalone executable version of the [Litestream](https://litestream.io/install/source/) utility. These executables are platform specific, so there are actually separate underlying gems per platform, but the correct gem will automatically be picked for your platform. Litestream itself doesn't support Windows, so this gem doesn't either.\n\nSupported platforms are:\n\n- arm64-darwin (macos-arm64)\n- x86_64-darwin (macos-x64)\n- arm64-linux (linux-arm64)\n- x86_64-linux (linux-x64)\n\n### Using a local installation of `litestream`\n\nIf you are not able to use the vendored standalone executables (for example, if you're on an unsupported platform), you can use a local installation of the `litestream` executable by setting an environment variable named `LITESTREAM_INSTALL_DIR` to the directory containing the executable.\n\nFor example, if you've installed `litestream` so that the executable is found at `/usr/local/bin/litestream`, then you should set your environment variable like so:\n\n```sh\nLITESTREAM_INSTALL_DIR=/usr/local/bin\n```\n\nThis also works with relative paths. If you've installed into your app's directory at `./.bin/litestream`:\n\n```sh\nLITESTREAM_INSTALL_DIR=.bin\n```\n\n## Usage\n\n### Configuration\n\nYou configure the Litestream executable through the [`config/litestream.yml` file](https://litestream.io/reference/config/), which is a standard Litestream configuration file as if Litestream was running in a traditional installation.\n\nThe gem streamlines the configuration process by providing a default configuration file for you. This configuration file will backup all SQLite databases defined in your `config/database.yml` file to one replication bucket. In order to ensure that no secrets are stored in plain-text in your repository, this configuration file leverages Litestream's support for environment variables. The default configuration file looks like this if you only have one SQLite database:\n\n```yaml\ndbs:\n  - path: storage/production.sqlite3\n    replicas:\n      - type: s3\n        bucket: $LITESTREAM_REPLICA_BUCKET\n        path: storage/production.sqlite3\n        access-key-id: $LITESTREAM_ACCESS_KEY_ID\n        secret-access-key: $LITESTREAM_SECRET_ACCESS_KEY\n```\n\nThis is the default for Amazon S3. The full range of possible replica types (e.g. other S3-compatible object storage servers) are covered in Litestream's [replica guides](https://litestream.io/guides/#replica-guides).\n\nThe gem also provides a default initializer file at `config/initializers/litestream.rb` that allows you to configure these three environment variables referenced in the configuration file in Ruby. By providing a Ruby interface to these environment variables, you can use any method of storing secrets that you prefer. For example, the default generated file uses Rails' encrypted credentials to store your secrets:\n\n```ruby\nRails.application.configure do\n  litestream_credentials = Rails.application.credentials.litestream\n\n  config.litestream.replica_bucket = litestream_credentials\u0026.replica_bucket\n  config.litestream.replica_key_id = litestream_credentials\u0026.replica_key_id\n  config.litestream.replica_access_key = litestream_credentials\u0026.replica_access_key\nend\n```\n\nHowever, if you need manual control over the Litestream configuration, you can manually edit the `config/litestream.yml` file. The full range of possible configurations are covered in Litestream's [configuration reference](https://litestream.io/reference/config/).\n\n### Replication\n\nIn order to stream changes to your configured replicas, you need to start the Litestream replication process.\n\nThe simplest way to run the Litestream replication process is use the Puma plugin provided by the gem. This allows you to run the Litestream replication process together with Puma and have Puma monitor and manage it. You just need to add the following to your `puma.rb` configuration:\n\n```ruby\n# Run litestream only in production.\nplugin :litestream if ENV.fetch(\"RAILS_ENV\", \"production\") == \"production\"\n```\n\nIf you would prefer to run the Litestream replication process separately from Puma, you can use the provided `litestream:replicate` rake task. This rake task will automatically load the configuration file and set the environment variables before starting the Litestream process.\n\nThe simplest way to spin up a Litestream process separately from your Rails application is to use a `Procfile`:\n\n```yaml\n# Procfile\nrails: bundle exec rails server --port $PORT\nlitestream: bin/rails litestream:replicate\n```\n\nAlternatively, you could setup a `systemd` service to manage the Litestream replication process, but setting this up is outside the scope of this README.\n\nIf you need to pass arguments through the rake task to the underlying `litestream` command, that can be done with argument forwarding:\n\n```shell\nbin/rails litestream:replicate -- -exec \"foreman start\"\n```\n\nThis example utilizes the `-exec` option available on [the `replicate` command](https://litestream.io/reference/replicate/) which provides basic process management, since Litestream will exit when the child process exits. In this example, we only launch our collection of Rails application processes (like Rails and SolidQueue, for example) after the Litestream replication process is ready.\n\nThe Litestream `replicate` command supports the following options, which can be passed through the rake task:\n\n```shell\n-config PATH\n    Specifies the configuration file.\n    Defaults to /etc/litestream.yml\n\n-exec CMD\n    Executes a subcommand. Litestream will exit when the child\n    process exits. Useful for simple process management.\n\n-no-expand-env\n    Disables environment variable expansion in configuration file.\n```\n\n### Restoration\n\nYou can restore any replicated database at any point using the gem's provided `litestream:restore` rake task. This rake task requires that you specify which specific database you want to restore. As with the `litestream:replicate` task, you pass arguments to the rake task via argument forwarding. For example, to restore the production database, you would run:\n\n```shell\nbin/rails litestream:restore -- --database=storage/production.sqlite3\n# or\nbundle exec rake litestream:restore -- --database=storage/production.sqlite3\n```\n\nYou can restore any of the databases specified in your `config/litestream.yml` file. The `--database` argument should be the path to the database file you want to restore and must match the value for the `path` key of one of your configured databases. The `litestream:restore` rake task will automatically load the configuration file and set the environment variables before calling the Litestream executable.\n\nIf you need to pass arguments through the rake task to the underlying `litestream` command, that can be done with additional forwarded arguments:\n\n```shell\nbin/rails litestream:replicate -- --database=storage/production.sqlite3 --if-db-not-exists\n```\n\nYou can forward arguments in whatever order you like, you simply need to ensure that the `--database` argument is present. You can also use either a single-dash `-database` or double-dash `--database` argument format. The Litestream `restore` command supports the following options, which can be passed through the rake task:\n\n```shell\n-o PATH\n    Output path of the restored database.\n    Defaults to original DB path.\n\n-if-db-not-exists\n    Returns exit code of 0 if the database already exists.\n\n-if-replica-exists\n    Returns exit code of 0 if no backups found.\n\n-parallelism NUM\n    Determines the number of WAL files downloaded in parallel.\n    Defaults to 8\n\n-replica NAME\n    Restore from a specific replica.\n    Defaults to replica with latest data.\n\n-generation NAME\n    Restore from a specific generation.\n    Defaults to generation with latest data.\n\n-index NUM\n    Restore up to a specific WAL index (inclusive).\n    Defaults to use the highest available index.\n\n-timestamp TIMESTAMP\n    Restore to a specific point-in-time.\n    Defaults to use the latest available backup.\n\n-config PATH\n    Specifies the configuration file.\n    Defaults to /etc/litestream.yml\n\n-no-expand-env\n    Disables environment variable expansion in configuration file.\n```\n\n### Verification\n\nYou can verify the integrity of your backed-up databases using the gem's provided `Litestream.verify!` method. The method takes the path to a database file that you have configured Litestream to backup; that is, it takes one of the `path` values under the `dbs` key in your `litestream.yml` configuration file. For example, to verify the production database, you would run:\n\n```ruby\nLitestream.verify! \"storage/production.sqlite3\"\n```\n\nIn order to verify that the backup for that database is both restorable and fresh, the method will add a new row to that database under the `_litestream_verification` table, which it will create if needed. It will then wait 10 seconds to give the Litestream utility time to replicate that change to whatever storage providers you have configured. After that, it will download the latest backup from that storage provider and ensure that this verification row is present in the backup. If the verification row is _not_ present, the method will raise a `Litestream::VerificationFailure` exception. This check ensures that the restored database file:\n\n1. exists,\n2. can be opened by SQLite, and\n3. has up-to-date data.\n\nAfter restoring the backup, the `Litestream.verify!` method will delete the restored database file. If you need the restored database file, use the `litestream:restore` rake task or `Litestream::Commands.restore` method instead.\n\n### Dashboard\n\nThe gem provides a web dashboard for monitoring the status of your Litestream replication. To mount the dashboard in your Rails application, add the following to your `config/routes.rb` file:\n\n```ruby\nauthenticate :user, -\u003e (user) { user.admin? } do\n  mount Litestream::Engine, at: \"/litestream\"\nend\n```\n\n\u003e [!NOTE]\n\u003e Be sure to [secure the dashboard](#authentication) in production.\n\n#### Authentication\n\nLitestream Rails does not restrict access out of the box. You must secure the dashboard yourself. However, it does provide basic HTTP authentication that can be used with basic authentication or Devise. All you need to do is setup a username and password.\n\nThere are two ways to setup a username and password. First, you can use the `LITESTREAM_USERNAME` and `LITESTREAM_PASSWORD` environment variables:\n\n```ruby\nENV[\"LITESTREAM_USERNAME\"] = \"frodo\"\nENV[\"LITESTREAM_PASSWORD\"] = \"ikeptmysecrets\"\n```\n\nSecond, you can configure the access credentials via the Rails configuration object, under the `litestream` key, in an initializer:\n\n```ruby\n# Set authentication credentials for Litestream\nconfig.litestream.username = Rails.application.credentials.dig(:litestream, :username)\nconfig.litestream.password = Rails.application.credentials.dig(:litestream, :password)\n```\n\nEither way, if you have set a username and password, Litestream will use basic HTTP authentication.\n\n\u003e [!IMPORTANT]\n\u003e If you have not set a username and password, Litestream will not require any authentication to view the dashboard.\n\nIf you use Devise for authentication in your app, you can also restrict access to the dashboard by using their `authenticate` constraint in your routes file:\n\n```ruby\nauthenticate :user, -\u003e (user) { user.admin? } do\n  mount Litestream::Engine, at: \"/litestream\"\nend\n```\n\n### Examples\n\nThere is only one screen in the dashboard.\n\n- the show view of the Litestream replication process:\n\n![screenshot of the single page in the web dashboard, showing details of the Litestream replication process](images/show-screenshot.png)\n\n### Usage with API-only Applications\n\nIf your Rails application is an API-only application (generated with the `rails new --api` command), you will need to add the following middleware to your `config/application.rb` file in order to use the dashboard UI provided by Litestream:\n\n```ruby\n# /config/application.rb\nconfig.middleware.use ActionDispatch::Cookies\nconfig.middleware.use ActionDispatch::Session::CookieStore\nconfig.middleware.use ActionDispatch::Flash\n```\n\n### Overwriting the views\n\nYou can find the views in [`app/views`](https://github.com/fractaledmind/litestream-ruby/tree/main/app/views).\n\n```bash\napp/views/\n├── layouts\n│   └── litestream\n│       ├── _style.html\n│       └── application.html.erb\n└── litestream\n    └── processes\n        └── show.html.erb\n```\n\nYou can always take control of the views by creating your own views and/or partials at these paths in your application. For example, if you wanted to overwrite the application layout, you could create a file at `app/views/layouts/litestream/application.html.erb`. If you wanted to remove the footer and the automatically disappearing flash messages, as one concrete example, you could define that file as:\n\n```erb\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eLitestream\u003c/title\u003e\n    \u003c%= csrf_meta_tags %\u003e\n    \u003c%= csp_meta_tag %\u003e\n\n    \u003c%= render \"layouts/litestream/style\" %\u003e\n  \u003c/head\u003e\n  \u003cbody class=\"h-full flex flex-col\"\u003e\n    \u003cmain class=\"container mx-auto max-w-4xl mt-4 px-2 grow\"\u003e\n      \u003c%= content_for?(:content) ? yield(:content) : yield %\u003e\n    \u003c/main\u003e\n\n    \u003cdiv class=\"fixed top-0 left-0 right-0 text-center py-2\"\u003e\n      \u003c% if notice.present? %\u003e\n        \u003cp class=\"py-2 px-3 bg-green-50 text-green-500 font-medium rounded-lg inline-block\"\u003e\n          \u003c%= notice %\u003e\n        \u003c/p\u003e\n      \u003c% end %\u003e\n\n      \u003c% if alert.present? %\u003e\n        \u003cp class=\"py-2 px-3 bg-red-50 text-red-500 font-medium rounded-lg inline-block\"\u003e\n          \u003c%= alert %\u003e\n        \u003c/p\u003e\n      \u003c% end %\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Introspection\n\nLitestream offers a handful of commands that allow you to introspect the state of your replication. The gem provides a few rake tasks that wrap these commands for you. For example, you can list the databases that Litestream is configured to replicate:\n\n```shell\nbin/rails litestream:databases\n```\n\nThis will return a list of databases and their configured replicas:\n\n```\npath                                                 replicas\n/Users/you/Code/your-app/storage/production.sqlite3  s3\n```\n\nYou can also list the generations of a specific database:\n\n```shell\nbin/rails litestream:generations -- --database=storage/production.sqlite3\n```\n\nThis will list all generations for the specified database, including stats about their lag behind the primary database and the time range they cover:\n\n```\nname  generation        lag     start                 end\ns3    a295b16a796689f3  -156ms  2024-04-17T00:01:19Z  2024-04-17T00:01:19Z\n```\n\nYou can list the snapshots available for a database:\n\n```shell\nbin/rails litestream:snapshots -- --database=storage/production.sqlite3\n```\n\nThis command lists snapshots available for that specified database:\n\n```\nreplica  generation        index  size     created\ns3       a295b16a796689f3  1      4645465  2024-04-17T00:01:19Z\n```\n\nFinally, you can list the wal files available for a database:\n\n```shell\nbin/rails litestream:wal -- --database=storage/production.sqlite3\n```\n\nThis command lists wal files available for that specified database:\n\n```\nreplica  generation        index  offset    size     created\ns3       a295b16a796689f3  1      0         2036     2024-04-17T00:01:19Z\n```\n\n### Running commands from Ruby\n\nIn addition to the provided rake tasks, you can also run Litestream commands directly from Ruby. The gem provides a `Litestream::Commands` module that wraps the Litestream CLI commands. This is particularly useful for the introspection commands, as you can use the output in your Ruby code.\n\nThe `Litestream::Commands.databases` method returns an array of hashes with the \"path\" and \"replicas\" keys for each database:\n\n```ruby\nLitestream::Commands.databases\n# =\u003e [{\"path\"=\u003e\"/Users/you/Code/your-app/storage/production.sqlite3\", \"replicas\"=\u003e\"s3\"}]\n```\n\nThe `Litestream::Commands.generations` method returns an array of hashes with the \"name\", \"generation\", \"lag\", \"start\", and \"end\" keys for each generation:\n\n```ruby\nLitestream::Commands.generations('storage/production.sqlite3')\n# =\u003e [{\"name\"=\u003e\"s3\", \"generation\"=\u003e\"5f4341bc3d22d615\", \"lag\"=\u003e\"3s\", \"start\"=\u003e\"2024-04-17T19:48:09Z\", \"end\"=\u003e\"2024-04-17T19:48:09Z\"}]\n```\n\nThe `Litestream::Commands.snapshots` method returns an array of hashes with the \"replica\", \"generation\", \"index\", \"size\", and \"created\" keys for each snapshot:\n\n```ruby\nLitestream::Commands.snapshots('storage/production.sqlite3')\n# =\u003e [{\"replica\"=\u003e\"s3\", \"generation\"=\u003e\"5f4341bc3d22d615\", \"index\"=\u003e\"0\", \"size\"=\u003e\"4645465\", \"created\"=\u003e\"2024-04-17T19:48:09Z\"}]\n```\n\nThe `Litestream::Commands.wal` method returns an array of hashes with the \"replica\", \"generation\", \"index\", \"offset\",\"size\", and \"created\" keys for each wal:\n\n```ruby\nLitestream::Commands.wal('storage/production.sqlite3')\n# =\u003e [{\"replica\"=\u003e\"s3\", \"generation\"=\u003e\"5f4341bc3d22d615\", \"index\"=\u003e\"0\",  \"offset\"=\u003e\"0\", \"size\"=\u003e\"2036\", \"created\"=\u003e\"2024-04-17T19:48:09Z\"}]\n```\n\nYou can also restore a database programmatically using the `Litestream::Commands.restore` method, which returns the path to the restored database:\n\n```ruby\nLitestream::Commands.restore('storage/production.sqlite3')\n# =\u003e \"storage/production-20240418090048.sqlite3\"\n```\n\nYou _can_ start the replication process using the `Litestream::Commands.replicate` method, but this is not recommended. The replication process should be managed by Litestream itself, and you should not need to manually start it.\n\n### Running commands from CLI\n\nThe rake tasks are the recommended way to interact with the Litestream utility in your Rails application or Ruby project. But, you _can_ work directly with the Litestream CLI. Since the gem installs the native executable via Bundler, the `litestream` command will be available in your `PATH`.\n\nThe full set of commands available to the `litestream` executable are covered in Litestream's [command reference](https://litestream.io/reference/), but can be summarized as:\n\n```shell\nlitestream databases [arguments]\nlitestream generations [arguments] DB_PATH|REPLICA_URL\nlitestream replicate [arguments]\nlitestream restore [arguments] DB_PATH|REPLICA_URL\nlitestream snapshots [arguments] DB_PATH|REPLICA_URL\nlitestream version\nlitestream wal [arguments] DB_PATH|REPLICA_URL\n```\n\n### Using in development\n\nBy default, if you install the gem and configure via `puma.rb` or `Procfile`, Litestream will not start in development.\n\nIf you setup via `puma.rb`, then remove the conditional statement.\n\nIf you setup via `Procfile`, you will need to update your `Procfile.dev` file. If you would like to test that your configuration is properly setup, you can manually add the `litestream:replicate` rake task to your `Procfile.dev` file. Just copy the `litestream` definition from the production `Procfile`. \n\nIn order to have a replication bucket for Litestream to point to, you can use a Docker instance of [MinIO](https://min.io/). MinIO is an S3-compatible object storage server that can be run locally. You can run a MinIO server with the following command:\n\n```sh\ndocker run -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address \":9001\"\n```\n\nThis gets us up and running quickly but it will only persist the data for as long as the Docker container is running, which is fine for local development testing.\n\nTo simplify local development, you can add this command to your `Procfile.dev` file as well. This would allow you to start a MinIO server and a Litestream replication process in your local development environment with the single `bin/dev` command.\n\nOnce you have a MinIO server running, you can create a bucket for Litestream to use. You can do this by visiting the MinIO console at [http://localhost:9001](http://localhost:9001) and logging in with the default credentials of `minioadmin` and `minioadmin`. Once logged in, you can create a bucket named `mybkt` by clicking the `+` button in the bottom right corner of the screen. You can then use the following configuration in your `config/initializers/litestream.rb` file:\n\n```ruby\nLitestream.configure do |config|\n  config.replica_bucket = \"s3://mybkt.localhost:9000/\"\n  config.replica_key_id = \"minioadmin\"\n  config.replica_access_key = \"minioadmin\"\nend\n```\n\nWith Litestream properly configured and the MinIO server and Litestream replication process running, you should see something like the following in your terminal logs when you start the `bin/dev` process:\n\n```sh\ntime=YYYY-MM-DDTHH:MM:SS level=INFO msg=litestream version=v0.3.xx\ntime=YYYY-MM-DDTHH:MM:SS level=INFO msg=\"initialized db\" path=/path/to/your/app/storage/development.sqlite3\ntime=YYYY-MM-DDTHH:MM:SS level=INFO msg=\"replicating to\" name=s3 type=s3 sync-interval=1s bucket=mybkt path=\"\" region=us-east-1 endpoint=http://localhost:9000\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\nFor maintainers, to release a new version, run `bin/release $VERSION`, which will create a git tag for the version, push git commits and tags, and push all of the platform-specific `.gem` files to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/fractaledmind/litestream-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/fractaledmind/litestream-ruby/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Litestream project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fractaledmind/litestream-ruby/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Flitestream-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffractaledmind%2Flitestream-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffractaledmind%2Flitestream-ruby/lists"}