From 537c255c75bfe2cb593029fc1b3f41e43dbc426b Mon Sep 17 00:00:00 2001 From: tb14 Date: Wed, 18 Dec 2019 02:12:02 -0800 Subject: [PATCH] Testing backup and restore scripts --- backup/backup-list.txt | 19 +++++++++++++++++++ backup/backup.sh | 19 +++++++++++++++++++ backup/restore.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 backup/backup-list.txt create mode 100755 backup/backup.sh create mode 100755 backup/restore.sh diff --git a/backup/backup-list.txt b/backup/backup-list.txt new file mode 100644 index 0000000..f51d51b --- /dev/null +++ b/backup/backup-list.txt @@ -0,0 +1,19 @@ +/etc/ssh/sshd_config +/etc/wpa_supplicant/wpa_supplicant.conf +/etc/hosts +/etc/hostname +/etc/chrony/ +/etc/dhcpcd.conf +/etc/ntp.conf +/etc/udev/rules.d/ +/home/pi/.ssh/authorized_keys +/home/pi/.ssh/config +/home/pi/.config/ +/home/pi/garim/ +/home/pi/.nbems/ +/home/pi/.fldigi/ +/home/pi/.wl2k/ +/home/pi/.conkyrc +/home/pi/.flrig/ +/home/pi/.gnupg/ +/home/pi/.gtktermrc diff --git a/backup/backup.sh b/backup/backup.sh new file mode 100755 index 0000000..b4c1ded --- /dev/null +++ b/backup/backup.sh @@ -0,0 +1,19 @@ +#!/bin/bash +NOW=$(date +"%m-%d-%Y") +FILE="backup.$NOW.tar.bz" + +echo "This script will backup the files and directories listed in $HOME/setup-scripts/backup/backup-list.txt" +echo +echo "The resulting compressed .tar.bz file can be used to restore most of your system's configuration settings after a fresh install." +echo +echo "Would you like to continue?" +echo +select yn in "Yes" "No"; do + case $yn in + Yes ) + tar -cvjf $FILE -T $HOME/setup-scripts/backup/backup-list.txt + break;; + + No ) break;; + esac +done diff --git a/backup/restore.sh b/backup/restore.sh new file mode 100755 index 0000000..3e5227c --- /dev/null +++ b/backup/restore.sh @@ -0,0 +1,41 @@ +#!/bin/bash +NOW=$(date +"%m-%d-%Y") +FILE=$1 + +if [[ -z ${1} ]]; then +echo "You must supply the full path to your backup file you with to restore." +echo +echo +echo "e.g. ./restore.sh /home/pi/setup-scripts/backups/backup.12-19-2019.tar.bz" +exit 0 + +else +clear +echo +echo +echo "WARNING: THIS WILL OVERWRITE YOUR SYSTEM WITH THE FILES FROM ${1}." +echo +echo +echo +echo "Do you wish to continue?" +select yn in "Yes" "No"; do +case $yn in + Yes ) sleep 1 + echo + echo + echo "Restoring ${1}...." + echo + echo + sleep 2 + tar -xvjf $FILE -C /tmp/testing || echo "A problem occured while extracting your backup" + echo + echo "${1} has been restored" + echo + sleep 1 + break;; + No ) break;; + esac +done + +fi +