This repository contains a script that automates the backup of the Bitcoin Lightning channel.backup
file to a remote Nextcloud server using rclone
. The script monitors changes to the backup file and uploads it to Nextcloud whenever it's updated.
- Monitors the
channel.backup
file for any changes, including timestamp updates. - Automatically copies the file to a remote Nextcloud directory using
rclone
. - Runs in the background and ensures the backup process continues after system restarts.
- rclone configured with your Nextcloud remote.
- inotify-tools for monitoring file changes.
- A working installation of Bitcoin Lightning on your device (e.g., Umbrel).
Install the required tools:
sudo apt update
sudo apt install inotify-tools rclone
Ensure you have rclone
configured with your Nextcloud account. You can set up the remote using the command:
rclone config
Follow the prompts to add a new remote for your Nextcloud instance. Here is an example of a remote configuration:
[bksd]
type = webdav
url = https://nextcloud.example.com/remote.php/webdav
vendor = nextcloud
user = your-username
pass = your-password
Clone this repository and copy the monitor_backup.sh
script to your local system:
git clone https://github.com/yourusername/lightning-channel-backup.git
cd lightning-channel-backup
Edit the monitor_backup.sh
file to match your setup. You’ll need to adjust the following variables:
-
FILE_TO_MONITOR
: The path to thechannel.backup
file on your system. For example:FILE_TO_MONITOR="$HOME/umbrel/app-data/lightning/data/lnd/data/chain/bitcoin/mainnet/channel.backup"
-
RCLONE_REMOTE
: Your Nextcloud remote configuration. For example:RCLONE_REMOTE="bksd:/backup"
To ensure the script runs automatically on system startup, you can configure it as a systemd
service.
-
Copy the script to a global location:
sudo cp monitor_backup.sh /usr/local/bin/ sudo chmod +x /usr/local/bin/monitor_backup.sh
-
Create a
systemd
service file:sudo nano /etc/systemd/system/monitor_backup.service
-
Add the following content to the service file:
[Unit] Description=Monitor Lightning Channel Backup File and Copy to Nextcloud After=network.target [Service] ExecStart=/usr/local/bin/monitor_backup.sh Restart=always User=your-username [Install] WantedBy=multi-user.target
-
Reload
systemd
to apply the changes:sudo systemctl daemon-reload
-
Enable and start the service:
sudo systemctl enable monitor_backup.service sudo systemctl start monitor_backup.service
You can also run the script manually by executing:
./monitor_backup.sh
You can check if the backup file has been copied successfully by logging into your Nextcloud instance or by listing the contents of the remote directory using rclone
:
rclone ls bksd:/backup
If you've set the script to run as a service, you can view the logs using:
journalctl -u monitor_backup.service -f
This will give you real-time updates on the backup process.
Feel free to submit issues or pull requests to improve this script.
Note: Always ensure you securely store your credentials and sensitive data when configuring backup scripts for critical files like channel.backup
.
If you found this guide helpful and would like to support the project, consider making a donation. Your contributions help maintain and improve this resource.
You can send Bitcoin directly to the following address:
bc1qy0l39zl7spspzhsuv96c8axnvksypfh8ehvx3e
For faster and lower-fee donations, you can use the Lightning Network:
Thank you for your support!
This project is licensed under the MIT License.