Script to backup various other OpenWrt systems to a FTP storage.
It's not intended to run it at OpenWrt! Rather it's designed for a dedicated user account in a VM.
But feel free to adopt it to your needs…
# Create SSH keyfile
ssh-keygen -t ed25519 -C "$USER@$HOSTNAME"
# Backup script (content see below)
# DON'T FORGET TO REPLACE FTP PATH!
touch ~/openwrt-backup.sh
chmod +x ~/openwrt-backup.sh
editor ~/openwrt-backup.sh
touch ~/.netrc
chmod 0600 ~/.netrc
editor ~/.netrc
machine backup-destination.example.net
login yourstupidremoteusername
password yoursecretpassword
mkdir ~/.ssh
chmod 0700 ~/.ssh
editor ~/.ssh/config
Host *
User root
Host example-1
Hostname example-1-real-fqdn.local
Host example-2
Hostname example-2-real-fqdn.local
Host example-3
Hostname example-3-real-fqdn.local
touch /etc/dropbear/authorized_keys
chmod 0600 /etc/dropbear/authorized_keys
vi /etc/dropbear/authorized_keys
# Don't forget to place your SSH public key at the end! (~/.ssh/id_ed25519.pub from the controller)
no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty,command="sysupgrade -k -b -" ssh-ed25519 […]
ssh example-1 >/dev/null
ssh example-2 >/dev/null
ssh example-3 >/dev/null
~/openwrt-backup.sh example-1
~/openwrt-backup.sh example-2
~/openwrt-backup.sh example-3
Don't forget to inspect *.tar.gz
contents at the FTP storage 🧐
crontab -e
@weekly for host in example-1 example-2 example-3; do ~/openwrt-backup.sh "$host"; done
Not implemented yet.