Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Recovery using database #6874

Merged
merged 3 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions doc/beginners-guide/backup-and-recovery/recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: "Wallet recovery"
slug: "recovery"
excerpt: "Learn about various recovery methods."
hidden: false
---


## Recovery


### Using `emergency.recover`

- Copy the valid binary formatted `hsm_secret` into `$LIGHTNINGDIR` directory
- Copy the latest `emergency.recover` backup file into the `$LIGHTNINGDIR` before starting up the node
- Start `lightningd`
- Run `lightning-cli emergencyrecover` (RPC command)[https://docs.corelightning.org/reference/lightning-emergencyrecover] to recover all the channels on the node
- Wait until your peer force closes the channel and the node would automatically sweep the funds. This could take some time


### Using `--recover` flag

- Copy the latest `emergency.recover` backup file into the `$LIGHTNINGDIR` before starting up the node
- Start `lightningd --recover=<codex32secret>`. It will automatically generate your node's hsm_secret using the codex32 secret
- The node will initiate in offline mode. As a result, it won't establish connections with peers automatically
- Restart `lightningd`
- Run `lightning-cli emergencyrecover` (RPC command)[https://docs.corelightning.org/reference/lightning-emergencyrecover] to recover all the channels on the node


> 🚧
>
> **Only** recover from database if you are sure that it is **latest**.
>
> Snapshot-style backups of the lightningd database is **discouraged**, as _any_ loss of state may result in permanent loss of funds.
>
> See the [penalty mechanism](https://github.com/lightning/bolts/blob/master/05-onchain.md#revoked-transaction-close-handling) for more details.


### Using database

If you already have **latest** wallet backup and hsm_secret, it is technically not recovery. It is similar to restarting your lightning node.

- Copy the DB backup `lightningd.sqlite3` from your NFS backup directory into `$LIGHTNINGDIR` directory
- Either copy the valid binary formatted `hsm_secret` into `$LIGHTNINGDIR` directory and start `lightningd`
- Or start lightningd with recover flag (`lightningd --recover=<codex32secret>`)
- Note that `emergency.recover` backup file is not required here but you can copy it into `$LIGHTNINGDIR` directory (if exists)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Backup and recovery"
slug: "backup-and-recovery"
excerpt: "Learn the various backup and recovery options available for your Core Lightning node."
title: "Backup your wallet"
slug: "backup"
excerpt: "Learn the various backup options available for your Core Lightning node."
hidden: false
createdAt: "2022-11-18T16:28:17.292Z"
updatedAt: "2023-04-22T12:51:49.775Z"
Expand Down Expand Up @@ -113,32 +113,3 @@ lightningd also stores detailed information of funds locked in Lightning Network
Real-time database replication is the recommended approach to backing up node data. Tools for replication are currently in active development, using the db write plugin hook.

Click [here](doc:advanced-db-backup) to learn more about advanced DB backup methods.


## Recovery

> 🚧
>
> **Only** recover from database if you are sure that it is **latest**.
>
> Snapshot-style backups of the lightningd database is **discouraged**, as _any_ loss of state may result in permanent loss of funds.
>
> See the [penalty mechanism](https://github.com/lightning/bolts/blob/master/05-onchain.md#revoked-transaction-close-handling) for more details.


### Using `emergency.recover`

- Copy the valid binary formatted `hsm_secret` into `$LIGHTNINGDIR` directory
- Copy the latest `emergency.recover` backup file into the `$LIGHTNINGDIR` before starting up the node
- Start `lightningd`
- Run `lightning-cli emergencyrecover` (RPC command)[https://docs.corelightning.org/reference/lightning-emergencyrecover] to recover all the channels on the node.
- Wait until your peer force closes the channel and the node would automatically sweep the funds. This could take some time.


### Using `--recover` flag

- Copy the latest `emergency.recover` backup file into the `$LIGHTNINGDIR` before starting up the node
- Start `lightningd --recover=<codex32secret>`. It will automatically generate your node's hsm_secret using the codex32 secret.
- The node will initiate in offline mode. As a result, it won't establish connections with peers automatically.
- Restart `lightningd`.
- Run `lightning-cli emergencyrecover` (RPC command)[https://docs.corelightning.org/reference/lightning-emergencyrecover] to recover all the channels on the node.
Loading