{"id":17204644,"url":"https://github.com/darwin/lnd-auto-backup","last_synced_at":"2025-06-12T05:31:51.556Z","repository":{"id":48019029,"uuid":"179768114","full_name":"darwin/lnd-auto-backup","owner":"darwin","description":"A simple automatic backup service for your LND node","archived":false,"fork":false,"pushed_at":"2021-08-10T23:26:48.000Z","size":42,"stargazers_count":44,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T03:08:18.764Z","etag":null,"topics":["backup","inotify","lnd","rsync","s3","systemd-service"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darwin.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-05T23:36:22.000Z","updated_at":"2025-06-02T14:58:35.000Z","dependencies_parsed_at":"2022-08-12T16:50:25.614Z","dependency_job_id":null,"html_url":"https://github.com/darwin/lnd-auto-backup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/darwin/lnd-auto-backup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darwin%2Flnd-auto-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darwin%2Flnd-auto-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darwin%2Flnd-auto-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darwin%2Flnd-auto-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darwin","download_url":"https://codeload.github.com/darwin/lnd-auto-backup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darwin%2Flnd-auto-backup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259404196,"owners_count":22852138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","inotify","lnd","rsync","s3","systemd-service"],"created_at":"2024-10-15T02:22:41.898Z","updated_at":"2025-06-12T05:31:51.540Z","avatar_url":"https://github.com/darwin.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LND auto backup service\n\nThis is a channel backup script for LND node (prepared to be installed as a systemd service). \n\nThe script uses `inotifywait` to monitor for file changes and triggers a new time-stamped backup when needed.\nThe backup script can do anything. As an example, we provide optional backup to Amazon S3 or via rsync. \nOr you can specify your own custom script.\n\nSee [https://github.com/lightningnetwork/lnd/pull/2313](https://github.com/lightningnetwork/lnd/pull/2313) for details.\n\n#### More reading\n\n* [Alex Bosworth's example](https://twitter.com/alexbosworth/status/1114650312592072704)\n* [Patrick Lemke's medium post](https://medium.com/@patricklemke95/how-to-backup-your-lightning-network-channels-170c995c157b)\n* [Rahil Shaikh's medium post](https://medium.com/@rahil471/enable-channel-backups-and-fund-recovery-on-lnd-lightning-network-3f27be42eb43)\n\n### Prerequisites\n\n* `apt install inotify-tools`\n\n### Setup\n\n1. `git clone --depth=1 https://github.com/darwin/lnd-auto-backup.git` \n2. `cd lnd-auto-backup`\n3. create a `.envrc` with content:\n\n```\n# for S3 backup (optional)\n# also don't forget to `apt install awscli`\n# note: S3 secrets can be configured via `aws configure`\nexport LNDAB_S3_BUCKET=your_bucket_name \n\n# for rsync backup (optional)\n# note: ssh access keys must be configured on the machine\nexport LNDAB_RSYNC_TARGET=user@server:/remote/path/to/backup/dir\n\n# for custom backup (optional)\nexport LNDAB_CUSTOM_BACKUP_SCRIPT=path/to/your/script.sh \n\n# these are optional:\n#\n#   export LND_HOME=/root/.lnd # if differs from $HOME/.lnd\n#   export LND_NETWORK=mainnet\n#   export LND_CHAIN=bitcoin\n#   export LNDAB_CHANNEL_BACKUP_PATH=/custom/path/to/channel.backup\n#   export LNDAB_VERBOSE=1\n#   export LNDAB_S3_BACKUP_SCRIPT=./backup-via-s3.sh\n#   export LNDAB_RSYNC_BACKUP_SCRIPT=./backup-via-rsync.sh\n```\n4. modify `LNDAB_HOME` in `./service/lnd-auto-backup.service` to point to the right directory, also review other service settings\n5. `./service/install.sh`\n6. `./service/start.sh` - start it!\n7. `./service/status.sh` - just to check the status \n8. `./service/enable.sh` - if it looks good, enable service launching after system restart\n\nNote: The service runs under the root privileges by default. You can change it by setting User/Group in `.service` config file. \nYou should perform `aws configure` under the same user. Or make sure `$HOME/.aws` folder is at expected place with correct permissions. \n\n### Typical workflow\n\n#### Run it directly (for testing)\n\n1. set env vars, or source `.envrc` or better use `direnv`\n2. `./monitor.sh`\n\n#### Check that the backup is working\n\n```sh\ntouch /path/to/.lnd/data/chain/bitcoin/mainnet/channel.backup\n```\n\n#### See service logs\n\n`./service/logs.sh`\n\n#### See service status\n\n`./service/status.sh`\n\n#### Stop the service\n\n`./service/stop.sh`\n\n#### Disable the service\n\n`./service/disable.sh`\n\n#### Update from git\n\n```sh\ncd lnd-auto-backup\ngit pull\n./service/restart.sh \n# you may be prompted to do `systemctl daemon-reload` if needed, then you need to restart it again\n```\n\n---\n\nTested on Ubuntu 19.04 server. My lnd node runs in a docker container and I use this service to monitor changes of \n`channel.backup` file mapped to host machine via a docker volume.\n\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://tiphub.io/user/651358055/tip?site=github\"\u003e\n    \u003cimg src=\"https://tiphub.io/static/images/tip-button-light.png\" alt=\"Tip darwin on TipHub\" height=\"60\"\u003e\n    \u003cbr /\u003e\n    My pubkey starts with \u003ccode\u003e03e24db0\u003c/code\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarwin%2Flnd-auto-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarwin%2Flnd-auto-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarwin%2Flnd-auto-backup/lists"}