Last active
July 28, 2024 05:44
-
-
Save mbierman/98be7f57a58ff32d1da3348e93371b8a to your computer and use it in GitHub Desktop.
Backup for Firewalla Gold / Purple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #variables | |
| add=${1:-40} | |
| backuphost=192.168.0.$add | |
| user=michael | |
| basedir=/Users/$user/Documents/Applications/Firewalla/backup | |
| echo "Backing up to $backuphost" | |
| echo -n "Enter your password and press [ENTER]: " | |
| read -s password | |
| rsync -ratiz --exclude={'lost*d','_*','redis','fake-hwclock.data','patch','tmp','homebridge/homebridge.log','homebridge/package-lock.json','homebridge/ui-wallpaper.jpg'} --delete-excluded --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" /data/ $user@$backuphost:$basedir/data | |
| rsync -ratiz --delete-excluded --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" /home/pi/.firewalla/run/docker/ $user@$backuphost:$basedir/docker | |
| rsync -ratiz --progress --delete-excluded --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" /home/pi/.firewalla/config/post_main.d/ $user@$backuphost:$basedir/config/post_main.d | |
| rsync -ratiz --progress --delete-excluded --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" /home/pi/.firewalla/config/dnsmasq_local/ $user@$backuphost:$basedir/config/dnsmasq_local | |
| rsync -rtiz --delete-excluded --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" /home/pi/.firewalla/config/user_crontab $user@$backuphost:$basedir/config | |
| rsync -rtiz --delete-excluded --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" /home/pi/.vimrc $user@$backuphost:$basedir/vimrc | |
| echo "backup complete" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # v 1.2 | |
| # Variables | |
| add=${1:-40} # Default value of 40 if no argument is provided | |
| backuphost=192.168.0.$add | |
| user=michael | |
| basedir=/Users/$user/Documents/Applications/Firewalla/backup | |
| echo "Backing up to $backuphost" | |
| echo -n "Enter your password and press [ENTER]: " | |
| read -s password | |
| # Ensure sudo is required early in the script | |
| sudo -v | |
| # Rsync commands to backup data | |
| sudo rsync -ratiz --exclude={'lost*d','_*','redis','fake-hwclock.data','patch','tmp','homebridge/homebridge.log','homebridge/package-lock.json','homebridge/ui-wallpaper.jpg'} --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" $user@$backuphost:$basedir/data/ /data | |
| sudo rsync -ratiz --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" $user@$backuphost:$basedir/docker/ /home/pi/.firewalla/run/docker | |
| sudo rsync -ratiz --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" $user@$backuphost:$basedir/config/ /home/pi/.firewalla/config | |
| sudo rsync -ratiz --progress --rsh="/usr/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no -l $user" $user@$backuphost:$basedir/vimrc/ /home/pi/.vimrc | |
| # Fixing permissions | |
| echo "Fixing permissions..." | |
| cd /data || exit | |
| sudo chown pi:pi *.sh *.txt *.data | |
| sudo chown -R pi:pi homebridge | |
| sudo chown -R pi:pi /home/pi/.firewalla/run/docker | |
| sudo chown -R pi:pi /home/pi/.firewalla/config/post_main.d | |
| echo "Restore complete" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Install in /home/pi/.firewalla/config/post_main.d | |
| installcheck=$(which sshpass) | |
| echo $installcheck | |
| if [ -n "$installcheck" ] ; then | |
| echo -e "\n\nsshpass instaleld!\n bye" | |
| exit | |
| fi | |
| unalias apt | |
| unalias apt-get | |
| sudo apt-get update -y | |
| sudo apt-get install -y sshpass |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a quick way to backup some of the files on Firewalla Gold and Purple that are removed if you have to reimage the device. Should work on Gold or Purple. You have to enter the password of the device you are copying to. I didn't want to use sshkeys so I installed sshpass and enter the password. You can automate this by placing the install_ssh.sh script in
/home/pi/.firewalla/config/post_main.d. This script will always install sshpass if it is not already installed after every reboot.Obviously update the following as needed:
The restore script could use some more generalization. It works for my specific use case and I need to take time to make it more generic.