Last active
August 24, 2019 22:58
-
-
Save Diegus83/4e26d077a0bc4d5698906c41ccc6bcd2 to your computer and use it in GitHub Desktop.
Simple pihole backup via SCP
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 | |
#################################### | |
# | |
# Backup via SCP | |
# | |
# Executes daily as defined by crontab -e | |
# 0 0 * * * bash /home/pi/scripts/backup.sh | |
# | |
# Don't forget to generate an ssh key and add it to the mac mini | |
# | |
#################################### | |
#Create empty exclusion list | |
touch /home/pi/scripts/exclude.txt | |
# What to backup | |
backup_files="/etc/pihole/blacklist.txt /etc/pihole/whitelist.txt /etc/hostname /etc/hosts /home/pi" | |
# Where to backup to. | |
#dest="/home/pi/backups/" | |
remote_user="####" | |
remote_machine="####" | |
# Create archive filename. | |
day=$(date +%A) | |
hostname=$(hostname -s) | |
archive_file="$hostname-$day.tgz" | |
# Backup and skip local storage to save SD life. | |
sudo tar -cz --exclude-from=/home/pi/scripts/exclude.txt $backup_files | ssh -l $remote_user $remote_machine "cat >/Users/####/etc/backups_pihole/$archive_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment