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

WIP: Add clightning backup plugin #415

Closed
wants to merge 4 commits into from

Conversation

jonasnick
Copy link
Member

No description provided.

@jonasnick jonasnick force-pushed the clightning-backup branch 2 times, most recently from 9ddd3e6 to 1e3d99e Compare October 31, 2021 13:16
@jonasnick
Copy link
Member Author

TODO: clightning fails with "Could not find backup.lock in the lightning-dir". Yet, backup.lock clearly exists in the lightning-dir.

Was able to fix this by using strace which showed that the plugin's working directory is actually dataDir/bitcoin

Now need to figure out a good way to give clightning (and clightning-backup-init) permissions to write into an arbitrary directory and not just clightnings dataDir.

cfg = config.services.clightning.plugins.backup;
nbLib = config.nix-bitcoin.lib;
nbPkgs = config.nix-bitcoin.pkgs;
clightningCfg = config.services.clightning;
Copy link
Member

@nixbitcoin nixbitcoin Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call this clightning in other modules...

config = mkIf cfg.enable {
assertions = [
{ assertion = cfg.backendURL != "";
message = "You must set system.services.clightning.plugins.backup.backendURL";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be config.services.clightning.plugins.backup.backendURL?

backupLock="${clightningCfg.networkDir}/backup.lock"
if [[ ! -e $backupLock || $backendURL != $(cat $backupLock | ${pkgs.jq}/bin/jq -r .backend_url) ]]; then
umask u=rw,go=
${backupPkg}/backup-cli init --lightning-dir "${clightningCfg.networkDir}" ${cfg.backendURL}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add ${backupPkg}/backup-cli to the system packages for restores?

@seberm
Copy link
Contributor

seberm commented Nov 8, 2021

@jonasnick
Please also do not forget to add an information about backup plugin into the README file (

* [clightning](https://github.com/ElementsProject/lightning) with support for announcing an onion service\
).

Thanks for your work!

script = ''
backendURL="${cfg.backendURL}"
backupLock="${clightningCfg.networkDir}/backup.lock"
if [[ ! -e $backupLock || $backendURL != $(cat $backupLock | ${pkgs.jq}/bin/jq -r .backend_url) ]]; then
Copy link
Member

@nixbitcoin nixbitcoin Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if backups get deleted on the remote? Shouldn't this script check the presence of the files, and reinit if necessary?

@nixbitcoin
Copy link
Member

nixbitcoin commented Nov 9, 2021

Tested the backup plugin in production with a rclone/webdav/nextcloud directory mounted by a systemd service in clightning.dataDir. A lot of manual fiddling but it works.

EDIT: Apparently the file gets edited on every update, so it is reuploaded every single time. This makes it unusable with remote backends without something like rsync.

EDIT2: Tried it with SSHFS, working smoothly now.

@erikarvstedt
Copy link
Collaborator

Superseded by #415.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants