Bonus guide: Automatic backup of static.channel to your Dropbox
Difficulty: easy
Since lnd V0.6, Static Channel Backups (SCB) is supported. In a nutshell, every time a channel changes, lnd writes a new copy of the channels.backup file. For more details, see v0.6-beta Release Notes This guide explains one way to automatically upload the channels.backup file on changes, to your Dropbox The following scripts were created by Vindard
Risk : Minimal
The channel.backup file is encrypted so that it is safe to transmit over the Internet and to store on (e.g.) a cloud server.
Requirements: lnd version higher than 0.6
Setup Dropbox API Key
In your web browser, do the following:
- Go to https://www.dropbox.com/developers/apps/create and sign in
- For section 1 (Choose an API), select Scoped access NEW
- For section 2 (Choose the type of access you need), select App Folder
- For section 3 (Name your app), name your app and click Create App to proceed
- Go to the Permission tab, and in the Files and folders section, select files.metadata.write, files.content.write and files.content.read
- Click the Submit button in the pop-up window at the bottom of the screen.
- Go back to the Settings tab, scroll down to OAuth 2
- For Access token expiration, select No expiration
- Click Generate
- You will now see a string of letters, numbers and special characters 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.
Preparation on the RaspiNail
As user “admin”, download the script, make it executable and move to the global bin folder.
$ cd /tmp/
$ wget https://gist.githubusercontent.com/vindard/e0cd3d41bb403a823f3b5002488e3f90/raw/4bcf3c0163f77443a6f7c00caae0750b1fa0d63d/lnd-channel-backup.sh
# check script & modify with your <dropbox-api-token> (third line, place the token string inside the double quotes)
$ sudo nano lnd-channel-backup.sh
$ sudo chmod +x lnd-channel-backup.sh
$ sudo mv lnd-channel-backup.sh /usr/local/bin
Setup script as systemd
service (start automatically on system startup)
$ sudo nano /etc/systemd/system/backup-channels.service
[Service]
ExecStart=/usr/local/bin/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
$ sudo journalctl -fu backup-channels
Run at boot
$ sudo systemctl enable backup-channels
Test
You will now cause the channel.backup to change and see if the copy gets uploaded to your webserver.
$ sudo touch /home/bitcoin/.lnd/data/chain/bitcoin/mainnet/channel.backup
Logon to your dropbox and see if you have a new file.
« Back: Bonus guides