Skip to content

Instantly share code, notes, and snippets.

@crabdancing
Created October 5, 2021 10:33
Show Gist options
  • Save crabdancing/4c505d8f1ad6fe1dcd6fd16612af2b25 to your computer and use it in GitHub Desktop.
Save crabdancing/4c505d8f1ad6fe1dcd6fd16612af2b25 to your computer and use it in GitHub Desktop.
Automatically backup your OpenWRT router configuration to a local tarball under ~/Backups
#!/usr/bin/env bash
# script based on instructions from:
# https://openwrt.org/docs/guide-user/troubleshooting/backup_restore
router_hostname=mainrouter.lan
# Generate/update backup
ssh "$router_hostname" 'umask go=; sysupgrade -b /tmp/backup-${HOSTNAME}-$(date +%F).tar.gz'
# Download backup
mkdir -p ~/Backups/"$router_hostname"
scp root@"$router_hostname":/tmp/backup-*.tar.gz ~/Backups/"$router_hostname"
@crabdancing
Copy link
Author

@jstrot

Yes, that's definitely much better. Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment