enhancement: Improve the backup script

- Significantly decrease time it takes to save a backup
- Remove host dependency on 'zip' binary
- Preserve file attributes on backed-up files
- Avoid copying files on the pi itself to /tmp

Signed-off-by: Jeremy O'Brien <neutral@fastmail.com>
This commit is contained in:
Jeremy O'Brien
2019-10-31 13:18:42 -04:00
parent bd63f71a1d
commit 3efa96b292
2 changed files with 18 additions and 30 deletions

16
scripts/restore.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# name of the ethernet gadget interface on the host
UNIT_HOSTNAME=${1:-10.0.0.2}
# output backup zip file
BACKUP=${2:-pwnagotchi-backup.tgz}
# username to use for ssh
USERNAME=${3:-pi}
ping -c 1 "${UNIT_HOSTNAME}" >/dev/null || {
echo "@ unit ${UNIT_HOSTNAME} can't be reached, make sure it's connected and a static IP assigned to the USB interface."
exit 1
}
echo "@ restoring $BACKUP to $UNIT_HOSTNAME ..."
cat ${BACKUP} | ssh "${USERNAME}@${UNIT_HOSTNAME}" "sudo tar xzv -C /"