Beginner guide
By the end of this guide you will have an encryption key stored safely, a working configuration, a first encrypted backup that has been checked, and a daily schedule.
The guide uses the monero-lws defaults from the example configuration: the server runs as the user monero-lws, and its database is in /home/monero-lws/.bitmonero/light_wallet_server. If your setup differs, change the paths as you go. For a database that is not monero-lws, see Back up other LMDB databases afterwards.
What you need
- lmdb-lws-backup installed at
/usr/local/bin/lmdb-lws-backup. See Install. - The repository's
config.example.tomland the files insystemd/. - A Linux server with systemd, where you can use
sudo. - A safe place outside the server for the key: a password manager, or paper in a locked drawer.
- Free memory roughly equal to the size of the database, for the check after each backup.
Create the encryption key
The key is 32 random bytes, written as base64 text. This step writes it straight into a file that only root can read, so it never appears on screen or in your shell history.
Create the configuration folder and an empty key file with mode
600(owner only):bashsudo mkdir -p /etc/lmdb-lws-backup sudo install -m 600 /dev/null /etc/lmdb-lws-backup/key.envGenerate the key into it:
bashecho "LWS_BACKUP_KEY=$(head -c 32 /dev/urandom | base64)" | sudo tee /etc/lmdb-lws-backup/key.env > /dev/nullThe file now holds one line,
LWS_BACKUP_KEY=followed by the key.Save a copy of the key somewhere safe, away from the server and away from the backups:
bashsudo cat /etc/lmdb-lws-backup/key.envCopy the text after
LWS_BACKUP_KEY=into your password manager, then clear the terminal.
DANGER
Without this key, no backup can ever be decrypted. Keep at least one copy outside the server: if the server's disk fails, the copy in /etc is lost with it. Never store the key next to the backups: anyone with both can read every user's view keys.
Write the configuration
Copy the example configuration:
bashsudo cp config.example.toml /etc/lmdb-lws-backup/config.tomlOpen it for editing:
bashsudoedit /etc/lmdb-lws-backup/config.tomlCheck these settings:
toml[source] db_path = "/home/monero-lws/.bitmonero/light_wallet_server" [backup] destination_dir = "/var/backups/monero-lws" retention_days = 30 [encryption] key_env_var = "LWS_BACKUP_KEY" [logging] log_path = "/var/log/lmdb-lws-backup.log"db_pathis the folder holdingdata.mdbandlock.mdb(monero-lws's--db-path).destination_diris where backups go.key_env_varnames the environment variable that will hold the key; the systemd service fills it fromkey.env.Save and close the editor.
Prepare folders for the service user
The backup runs as the monero-lws user. That user must be able to write the backup folder and the log file, and must have write access to lock.mdb in the database folder (LMDB records every reader there, even read-only ones). monero-lws's own user already has that.
sudo install -d -m 700 -o monero-lws -g monero-lws /var/backups/monero-lws
sudo install -m 600 -o monero-lws -g monero-lws /dev/null /var/log/lmdb-lws-backup.logInstall the systemd units
From the repository folder:
sudo cp systemd/lmdb-lws-backup.service systemd/lmdb-lws-backup.timer /etc/systemd/system/
sudo systemctl daemon-reloadThe service runs one backup cycle as monero-lws, with the key loaded from /etc/lmdb-lws-backup/key.env. If your user, database folder or backup folder differ from the defaults, edit User, Group, BindPaths and ReadWritePaths in the service file first. See Schedule backups.
Take the first backup
Start one backup now:
bashsudo systemctl start lmdb-lws-backup.serviceThe command returns when the backup has finished. For a large database that can take a while.
Read the result:
bashjournalctl -u lmdb-lws-backup.service -n 20A successful run ends with a line in this form:
textbackup ok: /var/backups/monero-lws/lws-backup-20261109.lmdbbak.enc (<size>, <n> accounts, <seconds>s)That is the backup file, its encrypted size, the number of wallet accounts it holds, and how long the whole cycle took. If you see
backup failed:instead, the rest of the line says why; see Troubleshooting.List your backups:
bashsudo lmdb-lws-backup --config /etc/lmdb-lws-backup/config.toml --listYou see one row per backup, newest first, with columns
DATE,AGE,SIZE,ITEMS(accounts),SCAN-HEIGHTSandFILE.
In /var/backups/monero-lws there are now two files for today: lws-backup-YYYYMMDD.lmdbbak.enc, the encrypted backup, and lws-backup-YYYYMMDD.manifest.json, its summary. Both have mode 600.
Check a backup yourself
Every backup is checked automatically before it is kept, but you can check any backup again at any time. This needs the key, so the command loads key.env first:
sudo sh -c 'set -a; . /etc/lmdb-lws-backup/key.env; exec lmdb-lws-backup --config /etc/lmdb-lws-backup/config.toml --verify /var/backups/monero-lws/lws-backup-20261109.lmdbbak.enc'Replace the date with your backup's. A good backup prints verify ok: with its profile, account count, scan heights, table and row counts, size and checksum, ending with manifest: matches.
Running this check now also proves that the copy of the key in /etc works. Test the copy in your password manager the same way from time to time.
Turn on the daily schedule
sudo systemctl enable --now lmdb-lws-backup.timerThe timer runs the backup every day at 03:00 (server time), with up to 5 minutes of random delay. If the server is off at that time, it runs at the next boot. Check the next run with systemctl list-timers lmdb-lws-backup.timer.
What you learned
- The key lives in
/etc/lmdb-lws-backup/key.envand, just as important, in a safe place off the server. - The configuration is
/etc/lmdb-lws-backup/config.toml. - Each backup is an encrypted
.lmdbbak.encfile plus a.manifest.jsonsummary. --listshows backups,--verifychecks one, and a systemd timer runs the backup daily.