Skip to content

Reference ​

Every option, setting and file of lmdb-lws-backup 0.2.0.

Command line ​

text
lmdb-lws-backup --config <file> --once
lmdb-lws-backup --config <file> --daemon
lmdb-lws-backup --config <file> --verify <backup-file>
lmdb-lws-backup --config <file> --list
lmdb-lws-backup --config <file> --restore <backup-file> --to <path>

Modes ​

Give exactly one.

ModeWhat it doesNeeds the key
--onceOne full cycle: copy, encrypt, verify, then retention. Exits.Yes
--daemonRuns until stopped, one cycle a day at schedule_time.Yes
--verify <file>Decrypts a backup in memory, reads every table, and compares it with its manifest.Yes
--listLists the backups in destination_dir with the configured prefix, newest first.No
--restore <file>Decrypts a backup to <path>/data.mdb. Requires --to.Yes

Options ​

OptionWhat it does
--config <file>Configuration file. Default /etc/lmdb-lws-backup/config.toml.
--db-path <path>Overrides [source] db_path.
--profile <p>Overrides [source] profile: auto, monero-lws or generic.
--destination <dir>Overrides [backup] destination_dir.
--retention-days <n>Overrides [backup] retention_days. 1 to 3650.
--to <path>Restore target folder. Only with --restore.
--helpPrints the usage text.
--versionPrints lmdb-lws-backup 0.2.0.

Every mode reads and checks the whole configuration, including that a key source is set, even --list.

Exit codes ​

CodeMeaning
0Success.
1The backup, verify or restore failed.
2Bad command line or invalid configuration.

Output ​

ModeOn success prints
--oncebackup ok: <file> (<size>, <n> accounts, <seconds>s), or total rows instead of accounts for the generic profile.
--verifyverify ok: <file>, then profile:, accounts: and scan height: (monero-lws), tables:, total rows:, plaintext bytes:, sha256: and manifest:.
--listColumns DATE, AGE, SIZE, ITEMS, SCAN-HEIGHTS, FILE. ITEMS is accounts (monero-lws) or rows (generic).
--restorerestored <file> -> <path>/data.mdb, a count summary, and a note that the folder holds decrypted data.

Failures print backup failed:, verify FAILED: or error: with the reason on standard error.

Configuration file ​

TOML. Unknown sections and keys are ignored with a warning in the log. A value of the wrong type is an error.

[source] ​

KeyDefaultWhat it sets
db_path/home/monero-lws/.bitmonero/light_wallet_serverThe LMDB environment to back up. Must not be empty.
profileautoauto, monero-lws or generic. See Profiles.
max_named_dbs128Named tables the tool can open, 1 to 4096.

[backup] ​

KeyDefaultWhat it sets
destination_dir/var/backups/monero-lwsWhere backups are written. Created with mode 700 if missing.
filename_prefixlws-backupFile name prefix, 1 to 100 characters from A-Za-z0-9._-, not starting with . or -.
retention_days30Days of backups to keep, 1 to 3650. See Retention.
schedule_time03:00Daily start time for --daemon, as HH:MM. Checked in every mode, used only by --daemon.
timezoneUTCUTC, local or an IANA name such as Asia/Kolkata. Sets the date in file names and the --daemon clock.
chunk_size1048576Encryption chunk size in bytes (1 MiB). At most 64 MiB.

[encryption] ​

Exactly one of the two keys must be set.

KeyWhat it sets
key_env_varName of the environment variable holding the base64-encoded 32-byte key.
key_filePath of a file holding the key, as 32 raw bytes or base64. Must be a regular file with no group or other permissions (mode 600).

[verify] ​

KeyDefaultWhat it sets
scratch_dirnot set (verify in RAM)Folder for the verify copy when RAM is short. Puts transient plaintext on that disk: use an encrypted volume.

[logging] ​

KeyDefaultWhat it sets
log_pathnot set (standard error only)Log file, created with mode 600. Warnings and errors also go to standard error.
levelinfodebug, info, warn or error.

[alerting] ​

KeyDefaultWhat it sets
on_failure_webhooknot setURL that receives a JSON POST when a backup or verify fails. Must start with http:// or https://. Needs the curl program.

The webhook body is:

json
{"event":"lmdb-lws-backup-failure","stage":"backup","error":"...","host":"...","timestamp":"..."}

stage is backup or verify. curl is given 15 seconds; a failed delivery is logged and does not change the exit code.

Files ​

FileContents
<prefix>-YYYYMMDD.lmdbbak.encThe encrypted backup. Mode 600.
<prefix>-YYYYMMDD.manifest.jsonThe manifest. Mode 600.
*.partialA backup being written. Renamed into place only after it verifies; removed at the start of the next run if left behind.

One backup per day per prefix. A second run on the same day replaces that day's files after the new backup verifies.

Manifest fields ​

FieldPresentMeaning
timestampalwaysWhen the backup was made (UTC).
profilealwaysmonero-lws or generic.
account_countmonero-lwsWallet accounts.
scan_height_min, scan_height_maxmonero-lwsLowest and highest account scan height, or null.
table_count0.2 and laterNamed tables.
total_rows0.2 and laterRows across all tables.
sha256_of_encrypted_filealwaysSHA-256 of the .enc file, checked by --verify.
encrypted_size_bytesalwaysSize of the .enc file.
tool_versionalwaysVersion that made the backup.

Manifests written by version 0.1 have no profile field. They are still read by --verify and --list, and retention still manages their backups.

Retention ​

After a new backup has been written and verified, the tool deletes old backups with the configured prefix. A backup is deleted only when both are true:

  1. Its file name date is older than retention_days days, counting today.
  2. It is not one of the newest retention_days backups.

Deletion goes oldest first, and each backup's manifest is deleted with it. With one backup a day, the two rules agree. After an outage they differ: if backups stopped for two months, the newest 30 are still kept, so a long gap never wipes out the only good backups. Nothing is deleted when a backup fails.

systemd units ​

FilePurpose
lmdb-lws-backup.serviceOne --once run as monero-lws, key from /etc/lmdb-lws-backup/key.env, with filesystem hardening.
lmdb-lws-backup.timerStarts the service daily at 03:00, up to 5 minutes random delay, catches up after downtime.
lmdb-lws-backup-daemon.serviceAlternative: runs --daemon, restarts on failure after 30 seconds.

Requirements ​

ItemRequirement
SystemLinux (uses memfd_create and /proc), x86-64 or ARM64
Prebuilt binaryx86-64; the project states glibc 2.38 or newer
AccessWrite access to the source environment's lock.mdb; write access to the destination and log
MemoryAbout the compacted database size, for verify (unless scratch_dir is set)
AlertsThe curl program, if on_failure_webhook is set

Next steps ​