litebackup 1.3.0-aarch64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2a70e5ba19f98b7427424f259d25d62ff572a2b5a74663dd3cf119c0213528c3
4
+ data.tar.gz: ba7bf8ce60dbc2e3836545d5537ebb537166d2791bfe2d12d66a0597189088a6
5
+ SHA512:
6
+ metadata.gz: 5cd39e5c07dd960b201e49eac749348a57dc90ef2dd381f20f88264200e7fe8730333dc1aec25eb8d5871535e87929da637f8b044d98128e781dcd61075f43c7
7
+ data.tar.gz: c15b2aeb6d4fd30722efc555d27d5750aa47aed10dd3bd5e0f7b7d3d793bf22bfd62aae806f92567bc301050a9d6f820816bd6df99466522801c36d89a719d94
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Litebackup
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # Litebackup for Ruby
2
+
3
+ Back up, replicate, and restore SQLite databases with your Litebackup server
4
+ and bucket, from Ruby and Rails. Ruby 3.2 or later on Linux or macOS. The gem
5
+ has no runtime dependencies; the sqlite3 adapter and the Rails integration
6
+ load those gems when you require them.
7
+
8
+ Install the gem from RubyGems, or add it to your `Gemfile`:
9
+
10
+ ```sh
11
+ gem install litebackup
12
+ export LITEBACKUP_API_KEY='JOIN_TOKEN@your-instance.litebackup.cloud'
13
+ ```
14
+
15
+ `LITEBACKUP_API_KEY` is the value from **Machines → Add machine**, or an API
16
+ key followed by @ and your server address. RubyGems and Bundler install the
17
+ platform gem for Linux (glibc and musl) or macOS, on x64 or arm64, which
18
+ carries the `litebackup` command without putting it on `PATH`. Elsewhere the
19
+ plain gem uses an installed `litebackup` command: install it with
20
+ `curl -fsSL https://litebackup.com/cli.sh | bash`, or set `LITEBACKUP_PATH`.
21
+
22
+ ## Back up an app's database
23
+
24
+ ```ruby
25
+ require "litebackup"
26
+ require "litebackup/integrations/sqlite3"
27
+
28
+ FileUtils.mkdir_p("data")
29
+ database = SQLite3::Database.new("data/app.sqlite")
30
+ Litebackup::Client.open do |litebackup|
31
+ rule = litebackup.backups.start(Litebackup::Integrations::SQLite3.database_path(database))
32
+ puts "#{rule.id} #{rule.name}"
33
+ end
34
+ ```
35
+
36
+ `backups.start` returns the saved rule when the same path was registered
37
+ with the same settings, so call it on every start. Different settings for a
38
+ saved path raise `rule_exists`, with the saved rule in `error.details["rule"]`.
39
+
40
+ ## Rails
41
+
42
+ Name the databases to back up in `config/application.rb`. Each is a database
43
+ of the environment's `config/database.yml`, the Solid Queue, Cache, and Cable
44
+ databases included:
45
+
46
+ ```ruby
47
+ require "litebackup/integrations/rails"
48
+
49
+ module App
50
+ class Application < Rails::Application
51
+ config.litebackup.databases = { primary: {}, queue: {}, cache: {}, cable: {} }
52
+ end
53
+ end
54
+ ```
55
+
56
+ The backups are registered after the app initializes, in every process that
57
+ boots it, with the same settings each time. Registration is off in the test
58
+ environment and in Rake tasks such as `assets:precompile` and `db:migrate`;
59
+ set `config.litebackup.enabled` to choose. The [Ruby guide](../docs/sqlite-ruby.md)
60
+ has the options.
61
+
62
+ ## Move a database between machines
63
+
64
+ A pool keeps a database open between calls. A lease locks the database for
65
+ this machine, so no other machine writes it, and keeps the lock until the
66
+ pool releases it:
67
+
68
+ ```ruby
69
+ require "litebackup"
70
+ require "litebackup/integrations/sqlite3"
71
+
72
+ Litebackup::Client.open do |litebackup|
73
+ litebackup.databases.pool(Litebackup::Integrations::SQLite3.adapter) do |pool|
74
+ pool.lease("agents/42.sqlite", path: "data/agents/42.sqlite", durability: "server") do |db|
75
+ db.execute("CREATE TABLE IF NOT EXISTS steps (body TEXT)")
76
+ db.execute("INSERT INTO steps (body) VALUES (?)", ["tests passed"])
77
+ end
78
+ end
79
+ end
80
+ ```
81
+
82
+ The adapter never commits: SQLite commits each statement outside a
83
+ transaction, and a transaction the block leaves open is rolled back when the
84
+ pool closes the database. A block that raises, or that it leaves with
85
+ `break` or `return`, keeps the lease and never offloads.
86
+
87
+ ## Errors
88
+
89
+ Every failure is a `Litebackup::Error` with `code`, `message`, `status`, and
90
+ `details`. `Litebackup::ErrorCode` names the codes worth matching:
91
+
92
+ ```ruby
93
+ begin
94
+ litebackup.databases.acquire("agents/42.sqlite", path: "data/agents/42.sqlite")
95
+ rescue Litebackup::Error => e
96
+ raise unless e.code == Litebackup::ErrorCode::LOCK_UNAVAILABLE
97
+
98
+ warn("another machine writes agents/42.sqlite; try again later")
99
+ end
100
+ ```
101
+
102
+ ## Development
103
+
104
+ `scripts/test` runs the tests and rubocop in `ruby:3.2.11-slim`,
105
+ `ruby:3.3.14-slim`, and `ruby:3.4.13-slim` as the calling user;
106
+ `scripts/test generate` regenerates `lib/litebackup/generated/models.rb` from
107
+ `../client-openapi.yaml`. The [SDK reference](../docs/sdk-reference.md) lists
108
+ every method, and [the contract](../docs/sdk-contract.md) the behavior the
109
+ Go, TypeScript, Python, and Ruby SDKs share.
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: data/lib/litebackup/bin/litebackup
3
+ size: 52085088 bytes
4
+ sha256: 217f7b32369747be31c0367f6a291960215f2373370c032727f2408bc4490ecb
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Litebackup
4
+ BINARY_PATH_ENVIRONMENT = "LITEBACKUP_PATH"
5
+
6
+ # Finding the litebackup binary. Nothing is downloaded at runtime.
7
+ module Binary
8
+ # Where a platform gem carries its binary. The gemspec lists it as a
9
+ # file, not an executable, so gem install writes no wrapper for it.
10
+ BUNDLED_PATH = File.join(__dir__, "bin", "litebackup")
11
+
12
+ module_function
13
+
14
+ # The one line that installs the litebackup command on Linux and macOS for whoever runs it.
15
+ def install_command
16
+ "curl -fsSL https://litebackup.com/cli.sh | bash"
17
+ end
18
+
19
+ def executable?(path)
20
+ File.file?(path) && File.executable?(path)
21
+ end
22
+
23
+ # The binary this platform's gem carries, or nil for the plain gem.
24
+ def bundled_binary
25
+ executable?(BUNDLED_PATH) ? BUNDLED_PATH : nil
26
+ end
27
+
28
+ # Finds the litebackup binary: the explicit path, then LITEBACKUP_PATH,
29
+ # then the binary the gem bundles, then litebackup on PATH, then
30
+ # ~/.local/bin/litebackup. Raises binary_not_found with the install
31
+ # command when there is none, or when the explicit path or LITEBACKUP_PATH
32
+ # names no file.
33
+ def litebackup_binary(environment = ENV, binary_path = nil)
34
+ override = binary_path.to_s.strip
35
+ override = environment[BINARY_PATH_ENVIRONMENT].to_s.strip if override.empty?
36
+ unless override.empty?
37
+ # An explicit path that names no file never falls back to another
38
+ # binary; a file that cannot run fails later, as launch_failed.
39
+ if missing_path?(override)
40
+ raise Error.new(
41
+ ErrorCode::BINARY_NOT_FOUND,
42
+ "the litebackup binary #{override} does not exist; " \
43
+ "set binary_path or #{BINARY_PATH_ENVIRONMENT} to it, or install it with: #{install_command}"
44
+ )
45
+ end
46
+ return override
47
+ end
48
+ bundled = bundled_binary
49
+ return bundled unless bundled.nil?
50
+
51
+ found = path_binary(environment["PATH"].to_s)
52
+ return found unless found.nil?
53
+
54
+ home = Wire.supplied?(environment["HOME"]) ? environment["HOME"] : Dir.home
55
+ local = File.join(home, ".local", "bin", "litebackup")
56
+ return local if executable?(local)
57
+
58
+ raise Error.new(
59
+ ErrorCode::BINARY_NOT_FOUND,
60
+ "the litebackup command is not installed; set #{BINARY_PATH_ENVIRONMENT} or install it with: #{install_command}"
61
+ )
62
+ end
63
+
64
+ # The first executable litebackup in a PATH value.
65
+ def path_binary(search_path)
66
+ search_path.split(File::PATH_SEPARATOR).reject(&:empty?).each do |directory|
67
+ candidate = File.join(directory, "litebackup")
68
+ return candidate if executable?(candidate)
69
+ end
70
+ nil
71
+ end
72
+
73
+ # Whether nothing is at path: it, or a directory on its way, does not
74
+ # exist. A path behind a directory this user may not enter is not missing.
75
+ def missing_path?(path)
76
+ File.stat(path)
77
+ false
78
+ rescue Errno::ENOENT, Errno::ENOTDIR
79
+ true
80
+ rescue SystemCallError
81
+ false
82
+ end
83
+
84
+ # Why starting binary failed. A file that is there but fails to start as
85
+ # missing cannot run: the interpreter its #! line names, or its dynamic
86
+ # loader, is not on this machine. The message names that line rather than
87
+ # repeating the file's path as if it were missing.
88
+ def start_failure_message(binary, error)
89
+ not_found = error.is_a?(Errno::ENOENT) || error.is_a?(Errno::ENOTDIR)
90
+ return "starting #{binary} failed: #{error.message}" if !not_found || missing_path?(binary)
91
+
92
+ interpreter_line = script_interpreter_line(binary)
93
+ unusable_binary = "starting #{binary} failed: it cannot run because"
94
+ return "#{unusable_binary} its interpreter or dynamic loader is not on this machine" if interpreter_line.empty?
95
+
96
+ "#{unusable_binary} the interpreter its first line names is not on this machine: #{interpreter_line}"
97
+ end
98
+
99
+ # The #! line that starts the file at path, or "" when it starts with none or cannot be read.
100
+ def script_interpreter_line(path)
101
+ start = File.binread(path, 256) || ""
102
+ first_line = start.split("\n", 2).first.to_s.force_encoding(Encoding::UTF_8).scrub
103
+ first_line.start_with?("#!") ? first_line.strip : ""
104
+ rescue SystemCallError, IOError
105
+ ""
106
+ end
107
+ end
108
+ end