Skip to content

Instantly share code, notes, and snippets.

@openoms
Last active March 19, 2024 19:56
Show Gist options
  • Save openoms/3516cd8f393d69d52f858c3d47c9e469 to your computer and use it in GitHub Desktop.
Save openoms/3516cd8f393d69d52f858c3d47c9e469 to your computer and use it in GitHub Desktop.
Restore a CLN node on a Raspiblitz from the database backup on the SDcard

make !backups to your desktop! of:

  • hsm_secret (this is the root key for your onchain funds - can be regenerated from the CLN backup words)
    • stored on the SSD: /home/bitcoin/.lightning/bitcoin/hsm_secret
  • lightningd.sqlite3.backup (this is the realtime channel database backup saved to your SDcard by the backup plugin)
    • find it on the SDcard in /home/bitcoin/. If there are multiple backup files always use the latest one (the backups of the backup are dated and stored when the backup plugin is reinitialized - they can be discarded).

To start the process flash a new SDcard (keep your old SDcard as a backup) and make sure everything is working by starting a new (empty) CLN node and have bitcoind synced.

Upload the backups from your desktop (can use WinSCP on Windows):

scp hsm_secret lightningd.sqlite3.backup admin@RASPIBLITZ_IP:~/

In the Raspiblitz terminal:

# stop CLN (running empty on the new setup - this will be gone):
sudo systemctl stop lightningd

# Copy the hsm_secret in place:
sudo cp /home/admin/hsm_secret /home/bitcoin/.lightning/bitcoin/hsm_secret

# fix permissions
sudo chown bitcoin:bitcoin /home/bitcoin/.lightning/bitcoin/hsm_secret
sudo chmod 0600 /home/bitcoin/.lightning/bitcoin/hsm_secret

# copy the lightningd.sqlite3.backup in place:
sudo cp /home/admin/lightningd.sqlite3.backup /home/bitcoin/lightningd.sqlite3.backup

# fix permissions
sudo chown bitcoin:bitcoin /home/bitcoin/lightningd.sqlite3.backup
sudo chmod 0600 /home/bitcoin/lightningd.sqlite3.backup

# restore backup
sudo -u bitcoin /home/bitcoin/cl-plugins-available/plugins/backup/backup-cli restore \
 file:///home/bitcoin/lightningd.sqlite3.backup \
  /home/bitcoin/.lightning/bitcoin/lightningd.sqlite3

# reinit the backup plugin for the restored node
/home/admin/config.scripts/cl-plugin.backup.sh on

# start CLN
sudo systemctl start lightningd

# monitor logs:
cllog

# for errors
sudo journalctl -fu lightningd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment