pwnagotchi/scripts/backup.sh

29 lines
741 B
Bash
Raw Normal View History

2019-10-03 15:55:03 +02:00
#!/usr/bin/env bash
# name of the ethernet gadget interface on the host
UNIT_HOSTNAME=${1:-10.0.0.2}
# output backup zip file
OUTPUT=${2:-pwnagotchi-backup.tgz}
# username to use for ssh
USERNAME=${3:-pi}
2019-10-03 15:55:03 +02:00
# what to backup
FILES_TO_BACKUP=(
/root/brain.nn
/root/brain.json
/root/.api-report.json
/root/.bashrc
2019-10-03 15:55:03 +02:00
/root/handshakes
/root/peers
2019-10-08 19:29:22 +02:00
/etc/pwnagotchi/
2019-10-03 15:55:03 +02:00
/var/log/pwnagotchi.log
/home/pi/.bashrc
2019-10-03 15:55:03 +02:00
)
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."
2019-10-03 15:55:03 +02:00
exit 1
}
echo "@ backing up $UNIT_HOSTNAME to $OUTPUT ..."
ssh "${USERNAME}@${UNIT_HOSTNAME}" "sudo tar cv ${FILES_TO_BACKUP[@]}" | gzip -9 > "$OUTPUT"