emissary-firmware/misc/script/restore.sh

18 lines
455 B
Bash
Executable File

#!/bin/bash
set -o pipefail
NOW=$(date +%Y-%m-%d)
BACKUP_DATE=${BACKUP_DATE:-${NOW}}
BACKUP_FILENAME="backup_${OPENWRT_DEVICE}_${NOW}.tar.gz"
printf "%s" "Waiting for ${OPENWRT_DEVICE} ..."
while ! ping -c 1 -n -w 1 ${OPENWRT_DEVICE} &> /dev/null
do
printf "%c" "."
done
printf "\n%s\n" "Server is back online"
scp "./tmp/backups/${BACKUP_FILENAME}" root@${OPENWRT_DEVICE}:/tmp/
ssh root@${OPENWRT_DEVICE} sysupgrade -r "/tmp/${BACKUP_FILENAME}"