lmdb-lws-backup
lmdb-lws-backup makes encrypted daily backups of an LMDB database while the program that uses it keeps running. It was built for the database of monero-lws, a Monero light wallet server, and works with any other LMDB database too.
LMDB (Lightning Memory-Mapped Database) is a small embedded key-value database. An LMDB environment is the folder that holds its two files, data.mdb and lock.mdb.
Why it exists
LMDB databases often hold secrets. The monero-lws database stores the view keys of its users' wallets in plain form. A view key lets anyone who has it see a wallet's incoming transactions. A backup of that database is just as sensitive as the database, so lmdb-lws-backup encrypts every backup and makes sure an unencrypted copy is never written to disk along the way.
What it does
- Hot backups. It copies the database through a read-only snapshot, so the running server is neither paused nor slowed by locks. (A hot backup is one taken while the database is in use.)
- Encrypts as it copies. The copy streams straight into authenticated encryption (XChaCha20-Poly1305), so plaintext never lands on disk.
- Verifies every backup. After writing a backup it decrypts it in memory, opens it as a database and reads every table. Only a backup that passes replaces the day's file.
- Keeps 30 days by default, deleting the oldest first, and never deletes the newest backups even after an outage.
- Writes a manifest next to each backup: counts, sizes and a checksum, never key material.
- Verifies, lists and restores existing backups on demand.
- Runs from a systemd timer, cron, or its own daily scheduler, and can call a webhook when a backup fails.
Who it is for
Operators of a monero-lws server, and anyone running another service on LMDB who needs encrypted, tested backups on a Linux server. You should be comfortable with the command line, sudo and systemd.
Platforms
Linux only, on x86-64 and ARM64. It relies on Linux-only features (memfd_create and /proc), so it does not run on Windows or macOS.
The current release is version 0.2.0, with a prebuilt binary for x86-64 Linux. On ARM64, or on older distributions, you build it from source. See Install.
DANGER
Every backup is encrypted with one key. If you lose the key, every backup is permanently unreadable. There is no recovery. Read Keys and security before you take your first backup.