This script was inspired by @alexbosworth's channel.backup
backup script and my own .lnd
folder backup script. It monitors lnd's channel.backup
file for changes and uploads those changes to Dropbox when detected.
To get started, download the script:
$ cd && wget -qN https://gist.githubusercontent.com/vindard/e0cd3d41bb403a823f3b5002488e3f90/raw/4bcf3c0163f77443a6f7c00caae0750b1fa0d63d/lnd-channel-backup.sh
$ sudo chmod +x lnd-channel-backup.sh
In your web browser, do the following:
-
Go to https://www.dropbox.com/developers/apps/create and sign in
-
Choose Dropbox Api
-
Choose App Folder
-
Name your app and click Create App to proceed
-
On the settings page for your new app, scroll down to OAuth 2 and click Generate
-
You will now see a string of letters and numbers appear. This is your Api Token. Copy this token and keep it safe for the next steps. This api token will be referenced as
<dropbox-api-token>
in the next step. -
Return to your terminal and run the following to insert the api token into the backup script:
$ TOKEN=<dropbox-api-token> $ cd && sed -i "s/DROPBOX_APITOKEN=\".*\"/DROPBOX_APITOKEN=\"$TOKEN\"/" lnd-channel-backup.sh $ unset TOKEN
Create file: sudo nano /etc/systemd/system/backup-channels.service
Note: be sure to change the <user-here>
value to your own home folder's name
[Service]
ExecStart=/home/<user-here>/lnd-channel-backup.sh
Restart=always
RestartSec=1
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=backup-channels
User=root
Group=root
[Install]
WantedBy=multi-user.target
Start
sudo systemctl start backup-channels
Monitor
journalctl -fu backup-channels
Run at boot
sudo systemctl enable backup-channels