]> code.delx.au - monosys/commitdiff
backup-openwrt
authorJames Bunton <jamesbunton@delx.net.au>
Mon, 14 Jun 2021 04:59:44 +0000 (14:59 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Mon, 14 Jun 2021 04:59:44 +0000 (14:59 +1000)
hacks/backup-openwrt [new file with mode: 0755]

diff --git a/hacks/backup-openwrt b/hacks/backup-openwrt
new file mode 100755 (executable)
index 0000000..59b8640
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+BACKUP_HOSTS="$(awk '/^Host.*openwrt/ {print $2}' < ~/.ssh/config)"
+
+cd ~/backup-openwrt/
+
+for host in $BACKUP_HOSTS; do
+    file="${host}.backup.tar.gz"
+    ssh "$host" sysupgrade -b - > "${file}.new" && mv "${file}.new" "${file}"
+done
+