Skip to content

This Elixir library wraps Litestream so that SQLite databases can be easily backed up

License

Notifications You must be signed in to change notification settings

akoutmos/litestream

Repository files navigation

Litestream Elixir Logo Litestream title

Easily backup your SQLite database right from Elixir using Litestream

Hex.pm GitHub Workflow Status (master) Support the project


Contents

Installation

Available in Hex, the package can be installed by adding litestream to your list of dependencies in mix.exs:

def deps do
  [
    {:litestream, "~> 0.4.0"}
  ]
end

Documentation can be found at https://hexdocs.pm/litestream.

Supporting Litestream

If you rely on this library to backup your SQLite databases, it would much appreciated if you can give back to the project in order to help ensure its continued development.

Checkout my GitHub Sponsorship page if you want to help out!

Gold Sponsors

Support the project

Silver Sponsors

Support the project

Bronze Sponsors

Support the project

Setting Up Litestream

After adding {:litestream, "~> 0.2.0"} in your mix.exs file and running mix deps.get, open your application.ex file and add the following to your supervision tree:

@impl true
def start(_type, _args) do
  children = [
    # Start the Ecto repository
    LitescaleTest.Repo,
    {Litestream, litestream_config()},
    ...
  ]

  opts = [strategy: :one_for_one, name: MyApp.Supervisor]
  Supervisor.start_link(children, opts)
end

defp litestream_config do
  Application.get_env(:my_app, Litestream)
end

In your runtime.exs (or dev.exs if you are just developing locally):

config :my_app, Litestream,
  repo: MyApp.Repo,
  replica_url: System.fetch_env!("REPLICA_URL"),
  access_key_id: System.fetch_env!("ACCESS_KEY_ID"),
  secret_access_key: System.fetch_env!("SECRET_ACCESS_KEY")

With those in place, you should be all set to go! As soon as your application starts, your database will be automatically synced with your remote destination.

Attribution

  • The logo for the project is an edited version of an SVG image from the unDraw project
  • The Litestream library that this library wraps Litestream

About

This Elixir library wraps Litestream so that SQLite databases can be easily backed up

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages