How to properly back up and secure a Lightning node: a practical guide
- 1. Know the three kinds of “backup”
- 2. Why an old channel database is toxic
- 3. Back up the seed once, properly
- 4. Automate the static channel backup
- 5. Encrypt everything that leaves the node
- 6. Run a watchtower
- 7. Rehearse a restore on signet
- 8. Harden the host
- 9. Disk, power and monitoring
- 10. Final checklist
- Going further
A Lightning node is a hot wallet with a database attached. It has to stay online, it has to keep its state, and it must never go back to an old state. That combination makes backups and security harder than for a normal server. This guide puts the pieces together in the order you actually need them: what to back up, what never to restore, how to get copies off the box safely, how to rehearse a recovery, and how to harden the machine so you need the recovery less often.
The examples use LND and Core Lightning (CLN) on a Debian/Ubuntu host with Bitcoin Core. Paths and flags differ between node distributions (Umbrel, Start9, RaspiBlitz, myNode), so check where your setup keeps its data before copying commands.
1. Know the three kinds of “backup”
There are three separate things people call a Lightning backup. Treat them as different objects with different rules.
The seed (or hsm_secret). LND uses a 24-word aezeed (plus an optional seed passphrase). CLN derives everything from hsm_secret, which you can export as a codex32 string or BIP39 words with lightning-hsmtool, depending on version. The seed restores your on-chain wallet and your node identity. It does not restore your channels.
The static channel backup. LND writes channel.backup (SCB). CLN writes emergency.recover. These files describe which channels exist and with whom. They do not contain balances or commitment states. After a restore, your node asks each peer to force-close the channel (Data Loss Protection), and your funds come back on-chain after the timelock. These files are safe to restore at any time, because they never replay an old state.
The channel database. LND’s channel.db and CLN’s lightningd.sqlite3 contain the live channel state. They change with every payment. A copy of them is only correct until the next update.
Rule of thumb: seed plus static channel backup are your disaster recovery. The live database is for running the node, not for restoring it.
2. Why an old channel database is toxic
Every Lightning payment creates a new commitment transaction and revokes the previous one. Your peer holds the revocation secrets for all your old states. If your node starts from an outdated database and broadcasts an old commitment, your peer can claim the whole channel balance with a penalty (justice) transaction.
So:
- Never start a node from a database snapshot that might be older than the last channel update.
- Never run two instances of the same node, for example an old SD card in a second Raspberry Pi “just to test”.
- If you migrate hardware, stop the node cleanly, move the data directory once, and make sure the old copy can never start again.
There is one safe way to keep a second database copy: a synchronous replica, where every write lands on both disks before the node continues. CLN supports this directly:
# lightningd config
wallet=sqlite3:///home/bitcoin/.lightning/bitcoin/lightningd.sqlite3:/mnt/usb/lightningd.sqlite3
The second path must sit on a different physical disk. With LND, the comparable route is a replicated database backend (etcd or PostgreSQL with synchronous replication), which is an advanced setup. For most home nodes: seed plus SCB, done well, is the realistic plan.
3. Back up the seed once, properly
- Write the seed by hand. No photos, no cloud notes, no password manager on the same machine as the node.
- Record the seed passphrase (if you set one) and the wallet unlock password separately, and record which software and version created the seed. aezeed words are not interchangeable with BIP39 tooling.
- For CLN, back up
hsm_secretitself or its exported codex32/mnemonic form. If you encrypted it, you also need the passphrase. - Store at least two copies in different physical places.
Test the words once, on a separate machine or signet node, before you put real money behind them.
4. Automate the static channel backup
channel.backup changes when you open or close a channel. A copy from last month will not know about the channels you opened last week. Manual copies get forgotten, so automate it.
Export and verify by hand first:
lncli exportchanbackup --all --output_file /tmp/channel.backup
lncli verifychanbackup --multi_file /tmp/channel.backup
LND rewrites the file at ~/.lnd/data/chain/bitcoin/mainnet/channel.backup on every change. It writes a temp file and renames it, so watch the directory, not the file:
#!/bin/sh
# /usr/local/bin/scb-watch.sh (needs inotify-tools and age)
DIR=/home/bitcoin/.lnd/data/chain/bitcoin/mainnet
RECIPIENT=age1yourpublickeyhere...
inotifywait -m -e close_write,moved_to --format '%f' "$DIR" | while read f; do
[ "$f" = "channel.backup" ] || continue
ts=$(date +%Y%m%d-%H%M%S)
age -r "$RECIPIENT" -o "/var/backups/scb/channel.backup.$ts.age" "$DIR/channel.backup"
rclone copy "/var/backups/scb/channel.backup.$ts.age" offsite:node-scb/
done
Run it as a systemd service with Restart=always, so it survives reboots. On CLN, apply the same loop to emergency.recover in ~/.lightning/bitcoin/. If you prefer an API over a file watcher, LND offers the SubscribeChannelBackups gRPC stream. Many node distributions also include an SCB-to-USB or SCB-to-cloud option. Use it, and still verify that it really runs.
Add an alert if no new backup has arrived within a few days after a channel open. A silent backup job is the classic failure.
5. Encrypt everything that leaves the node
An SCB in the clear does not give away keys, but it reveals your peers, channel points and node identity. A seed or hsm_secret in the clear is a theft risk. Encrypt before upload:
- age is simple and hard to misuse: keep the private key offline (printed or on a hardware token), and put only the public recipient on the node.
- GPG works too, if you already know it well.
Then follow a plain 3-2-1 pattern: three copies, two different media, one off-site. Examples: a USB stick attached to the node, a VPS or cloud bucket, and an occasional copy on a laptop. Check now and then that you can decrypt the latest file with the key you would actually have after a fire or burglary. A backup encrypted to a key that only lived on the dead node is worth nothing.
6. Run a watchtower
Backups protect you after your disk fails. They do nothing while you are offline and a peer broadcasts a revoked state. Once the to_self_delay (CSV) window passes, the funds are gone. Watchtowers watch the chain for you and broadcast the justice transaction.
LND client:
# lnd.conf
[wtclient]
wtclient.active=true
lncli wtclient add <tower_pubkey>@<tower_host>:9911
lncli wtclient towers
You can run your own tower on a second LND instance in another location (watchtower.active=true) and point your node at it, or use towers operated by people you trust. Better still, do both. CLN users can run the watchtower plugin from The Eye of Satoshi (teos). A watchtower does not replace SCB. It covers a different failure.
7. Rehearse a restore on signet
A backup you have never restored is a hope, not a plan. Do a full drill on signet or testnet:
- Start a fresh LND with
bitcoin.signet=true(or a signet CLN). - Fund it from a faucet, open one or two channels to public signet nodes.
- Export the seed and the SCB with your real backup pipeline, encryption included.
- Destroy the node: delete the data directory.
- Restore:
lncli createwith the existing seed, thenlncli restorechanbackup --multi_file channel.backup(CLN: restorehsm_secret, thenlightning-cli emergencyrecover). - Watch the peers force-close and the funds return on-chain after the CSV delay.
Write the exact steps into a runbook as you go: where the encrypted files live, which key decrypts them, which commands you ran, how long each step took. Put the runbook next to the seed backup, because the person running it may be a stressed version of you, or a family member.
Expect what you saw on signet on mainnet too: a static-backup restore means force-closes, on-chain fees and waiting, not a seamless resume. On mainnet, at least check regularly that the latest encrypted SCB decrypts and that lncli verifychanbackup accepts it.
8. Harden the host
Most node losses are not exotic attacks. They are weak SSH, exposed ports, outdated software and dead disks.
SSH. Keys only, no root login, and a limited user:
# /etc/ssh/sshd_config.d/10-hardening.conf
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
AllowUsers admin
sudo sshd -t && sudo systemctl reload ssh (the unit is sshd on some distributions). Keep a second session open while testing so you cannot lock yourself out. If possible, reach SSH only via LAN, WireGuard or Tor, not the open internet.
Firewall. Deny inbound by default, then open only what you need:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp
sudo ufw allow 9735/tcp # only if you accept clearnet Lightning peers
sudo ufw enable
Note that Docker-published ports can bypass ufw rules. If your node stack runs in Docker, check with ss -tlnp and an external port scan, not just ufw status.
Tor. Running both Bitcoin Core and LND over Tor hides your home IP:
# bitcoin.conf
proxy=127.0.0.1:9050
listen=1
bind=127.0.0.1
onlynet=onion
# lnd.conf
[tor]
tor.active=true
tor.v3=true
tor.streamisolation=true
Tor-only nodes have worse connectivity. Hybrid mode (Tor plus a clearnet address) is a trade-off between privacy and routing reliability. Decide on purpose.
RPC and API permissions. Bitcoin Core RPC should listen on localhost only (rpcbind=127.0.0.1, rpcallowip=127.0.0.1), with rpcauth instead of a plaintext rpcpassword. Do not hand admin.macaroon to every app. Bake a minimal one:
lncli bakemacaroon info:read offchain:read invoices:read invoices:write \
--save_to=/home/bitcoin/shop.macaroon
On CLN, use runes with restrictions, for example a read-only rune:
lightning-cli createrune restrictions='[["method^list|method^get"]]'
Treat every macaroon or rune with spend rights like a password. If a dashboard or web app leaks, you want it to leak only read.
Updates. Keep the OS patched (unattended-upgrades for security updates). For bitcoind, LND and CLN: read the release notes, back up the SCB before upgrading, and verify the release before installing:
sha256sum --check --ignore-missing manifest-v0.x.y.txt
gpg --verify manifest-<signer>-v0.x.y.sig manifest-v0.x.y.txt
Never upgrade during an open force-close or a stuck HTLC if you can avoid it.
9. Disk, power and monitoring
Disk. SD cards fail. Use an SSD for the chain and the node database, and watch it:
sudo smartctl -a /dev/sda | grep -Ei 'reallocated|pending|wear|percentage'
df -h /
A full disk can stop the node or corrupt the database. Alert at 80 %.
Power. Unclean shutdowns are a risk to the channel database. A small UPS with NUT (nut package) lets the node shut down cleanly before the battery runs out. Test that the shutdown actually happens.
Monitoring. You do not need a big stack. A cron job or a small script that checks a few things and sends you a message is enough:
lncli getinfo:synced_to_chainandsynced_to_graphare true, block height is current.lncli listchannels --inactive_only: alert when a channel stays inactive for hours.lncli pendingchannels: watch force-closes and their maturity height.lncli wtclient towers: towers are active and sessions are acknowledged.- Disk space, SMART status, last SCB upload time.
Send alerts through something that does not depend on the node itself, for example email or a Nostr DM from a separate machine.
10. Final checklist
Backups:
- [ ] Seed written by hand, two copies, two places; passphrase and unlock password recorded separately
- [ ] CLN:
hsm_secret(or its exported form) backed up - [ ]
channel.backup/emergency.recovercopied automatically on every change - [ ] Backups encrypted before leaving the node; decryption key stored off the node
- [ ] At least one off-site copy; restore-key access tested
- [ ] No old
channel.dborlightningd.sqlite3snapshot ever used for a restore - [ ] Alert if the backup job stops
Protection while offline:
- [ ] Watchtower client active, at least one tower (ideally two, in different places)
Restore:
- [ ] Full restore drill done on signet or testnet
- [ ] Written runbook stored with the seed backup
- [ ]
lncli verifychanbackup(or CLN equivalent) passes on the latest file
Host hardening:
- [ ] SSH keys only, no root login, not exposed to the internet
- [ ] Firewall default-deny; Docker port exposure checked
- [ ] Tor or hybrid chosen deliberately
- [ ] RPC on localhost with
rpcauth; apps use reduced macaroons or runes - [ ] OS patched; node releases verified with checksums and signatures before installation
Hardware and monitoring:
- [ ] SSD with SMART checks, disk-space alerts
- [ ] UPS with tested clean shutdown
- [ ] Sync, inactive channels, pending closes and tower status monitored, with alerts sent independently of the node
None of this is complicated on its own. The risk comes from doing half of it and assuming the rest. Pick the item you are least sure about, and test it this week.
Going further
If you want this as a working document instead of an article, Sats-Werkstatt has printable checklists that fit this guide:
- Bitcoin & Lightning Node Hardening and Backup Checklist (12,000 sats): copy-ready configs, Tor, firewall,
channel.backupautomation and a restore drill for Bitcoin Core + LND. 9-page PDF. https://zaps.cash/support/HR8H8x - Linux Server Hardening Checklist (8,000 sats): SSH, sysctl, ufw and auditd configs with check commands, for the host underneath your node. https://zaps.cash/support/Pr9nz5
- Backup & Disaster Recovery Checklist (1,700 sats): 3-2-1-1-0, encryption, restic/borg, and restore drills for everything else you run. https://zaps.cash/support/wOsX6n
All products: https://zaps.cash/@sats-werkstatt. Pay with Lightning, no account needed.
- Reference: https://zaps.cash/@sats-werkstatt
Write a comment