<p>The <code>hsm_secret</code> is used to derive keys for both onchain and offchain (channels commitments) transactions.</p>
<h3>On chain</h3>
<p>To retrieve on chain funds you can rescan the block chain for your utxos by using the <code>--rescan</code> startup option of <code>lightningd</code>.</p>
<h3>Off chain</h3>
<p>You <strong>can not</strong> re create the whole state of your channels just from the <code>hsm_secret</code>, which are stored in the database. Moreover it's very discouraged to restore from a backed up database (penalty transactions...).</p>
<p>Fortunately, with the <code>option_static_remotekey</code> now enabled by default you can now claim your funds onchain after your peer force closed the channel (if the channel was opened when both peers signaled this option).</p>
<p>The process is detailed <a href="https://github.com/ElementsProject/lightning/issues/3382" rel="nofollow noreferrer">here</a> as part of the C-lightning FAQ draft.</p>
<h2>How do i backup, in practice ?</h2>
<p>The different backup solutions currently available <a href="https://lightning.readthedocs.io/BACKUP.html" rel="nofollow noreferrer">are detailed here</a>.</p>

CC BY-SA 4.0
2020-01-14T16:40:20.290Z
2021-01-24T13:20:07.550Z
2021-01-24T13:20:07.550Z
Antoine Poinsot
<p>Hsm secret is only used to derive your keys but you need more than that - which is the state of your channels (meaning the most recent commitment transaction and revocstion secrets). This information can be found in your sql file in the <code>.lightning</code> directory. The problem is that this backup has to be made everytime the state of a channel changes (even failed routing attempts) there is a hook for the plugin api that triggers an event everytime something is written to the database. So I guess it would be best to create a plugin that streams out a replica of your dB writes to a remote backup </p>

CC BY-SA 4.0
2020-01-14T11:23:58.263Z
2020-01-14T11:23:58.263Z
Rene Pickhardt
<p>How do I restore a c-lightning node from  a backed up <code>hsm_secret</code> ?</p>
<p>I have tried running <code>lightningd</code> by replacing the generated <code>hsm_secret</code> with the backed-up one. It shows no output and no channel.<br />
How can I retrieve the funds in the node from there ?</p>

<lightning-network><backup><core-lightning><lightning-nodes>
c-lightning node backup-restore
Prashanth C
# c-lightning node backup-restore

(Asked by: username_0 on 2020-01-14)

How do I restore a c-lightning node from a backed up `hsm_secret` ?

I have tried running `lightningd` by replacing the generated `hsm_secret` with the backed-up one. It shows no output and no channel.  
How can I retrieve the funds in the node from there ?

**Tags:** lightning-network, backup, core-lightning, lightning-nodes


---

## 2 answers

### Answer by username_1 on 2020-01-14. Score: 5

The `hsm_secret` is used to derive keys for both onchain and offchain (channels commitments) transactions.

### On chain

To retrieve on chain funds you can rescan the block chain for your utxos by using the `--rescan` startup option of `lightningd`.

### Off chain

You **can not** re create the whole state of your channels just from the `hsm_secret`, which are stored in the database. Moreover it's very discouraged to restore from a backed up database (penalty transactions...).

Fortunately, with the `option_static_remotekey` now enabled by default you can now claim your funds onchain after your peer force closed the channel (if the channel was opened when both peers signaled this option).

The process is detailed [here](https://github.com/ElementsProject/lightning/issues/3382) as part of the C-lightning FAQ draft.

## How do i backup, in practice ?

The different backup solutions currently available [are detailed here](https://lightning.readthedocs.io/BACKUP.html).


---

### Answer by username_2 on 2020-01-14. Score: 2

Hsm secret is only used to derive your keys but you need more than that - which is the state of your channels (meaning the most recent commitment transaction and revocstion secrets). This information can be found in your sql file in the `.lightning` directory. The problem is that this backup has to be made everytime the state of a channel changes (even failed routing attempts) there is a hook for the plugin api that triggers an event everytime something is written to the database. So I guess it would be best to create a plugin that streams out a replica of your dB writes to a remote backup


---

