sudo apt install inotify-tools
Create a script file at the path of your choice: /path/copy-channel-backup-on-change.sh
#!/bin/bash
while true; do
inotifywait /path/to/.lnd/data/chain/bitcoin/mainnet/channel.backup
cp /path/to/.lnd/data/chain/bitcoin/mainnet/channel.backup /backup/path/channel.backup
done
chmod +x /path/copy-channel-backup-on-change.sh
Create file: sudo emacs /etc/systemd/system/backup-channels.service
[Service]
ExecStart=/path/copy-channel-backup-on-change.sh
Restart=always
RestartSec=1
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=backup-channels
User=ubuntu
Group=ubuntu
[Install]
WantedBy=multi-user.target
Start
sudo systemctl start backup-channels
Monitor
journalctl -fu backup-channels
Run at boot
sudo systemctl enable backup-channels
touch /path/to/.lnd/data/chain/bitcoin/mainnet/channel.backup
Look to see if the backup was updated
this is awesome. Trying to set it up on my raspiblitz where bitcoin and lnd were manually installed. The problem is I have 3 users: admin, bitcoin and root; and the channel.backup is in /home/bitcoin/.lnd/data/chain/bitcoin/mainnet, but I can only ssh to raspiblitz as admin. So I created copy-channel-backup-on-change.sh in /home/bitcoin as root for the script to copy channel.backup to /home/admin/backup so as I could rsync it there from a remote machine. The question is how to create a systemd service for it to work correctly? Thank you