From c32607f524b0167d8c9e89c6c894c3a492eb91b6 Mon Sep 17 00:00:00 2001 From: akanealw Date: Wed, 11 Oct 2023 12:24:07 -0500 Subject: [PATCH] updated wrestic local --- wrestic/install-wrestic-local.sh | 29 ++-------------------- wrestic/wrestic-backup-to-truenas-local.sh | 13 +++++++--- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/wrestic/install-wrestic-local.sh b/wrestic/install-wrestic-local.sh index 07fd23a..5f9fc2b 100644 --- a/wrestic/install-wrestic-local.sh +++ b/wrestic/install-wrestic-local.sh @@ -6,31 +6,6 @@ if [ "$EUID" -ne 0 ] exit fi -isInFile=$(cat /home/akanealw/.ssh/config | grep -c "truenas") -if [ $isInFile -eq 0 ] - then - echo "" >> /home/akanealw/.ssh/config - echo "Host truenas" >> /home/akanealw/.ssh/config - echo "Hostname 192.168.1.41" >> /home/akanealw/.ssh/config - echo "Port 22" >> /home/akanealw/.ssh/config - echo "User akanealw" >> /home/akanealw/.ssh/config - echo "IdentityFile ~/.ssh/truenas" >> /home/akanealw/.ssh/config - chmod 600 /home/akanealw/.ssh/config -fi - -if [[ ! -f /home/akanealw/.ssh/truenas ]] - then - echo "-----BEGIN OPENSSH PRIVATE KEY-----" > /home/akanealw/.ssh/truenas - echo "b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW" >> /home/akanealw/.ssh/truenas - echo "QyNTUxOQAAACCDKl0DNjKWKlSpbCGeKjmA3tc0pKDvAiMfWQ83h0JVlQAAAJhNQ67sTUOu" >> /home/akanealw/.ssh/truenas - echo "7AAAAAtzc2gtZWQyNTUxOQAAACCDKl0DNjKWKlSpbCGeKjmA3tc0pKDvAiMfWQ83h0JVlQ" >> /home/akanealw/.ssh/truenas - echo "AAAEBoM2bsFqToHCHKO3F6MvOlObGaiNXw6UPcyBlyfbSAvYMqXQM2MpYqVKlsIZ4qOYDe" >> /home/akanealw/.ssh/truenas - echo "1zSkoO8CIx9ZDzeHQlWVAAAAEWFrYW5lYWx3QExhcHRvcFBDAQIDBA==" >> /home/akanealw/.ssh/truenas - echo "-----END OPENSSH PRIVATE KEY-----" >> /home/akanealw/.ssh/truenas - chown akanealw:akanealw /home/akanealw/.ssh/truenas - chmod 600 /home/akanealw/.ssh/truenas -fi - if [[ ! -f /home/akanealw/.config/wrestic/wrestic.toml ]] then apt update @@ -39,8 +14,8 @@ if [[ ! -f /home/akanealw/.config/wrestic/wrestic.toml ]] mkdir -pv /home/akanealw/restic/restore mkdir -pv /root/restic/restore wget -qO /usr/local/bin/wrestic http://192.168.1.50/files/wrestic/wrestic - wget -qO /home/akanealw/.config/wrestic/wrestic.toml http://192.168.1.50/files/wrestic/wrestic.toml - wget -qO /home/akanealw/scripts/wrestic-backup-to-truenas.sh http://192.168.1.50/scripts/wrestic/wrestic-backup-to-truenas.sh + wget -qO /home/akanealw/.config/wrestic/wrestic.toml http://192.168.1.50/files/wrestic/wrestic-local.toml + wget -qO /home/akanealw/scripts/wrestic-backup-to-truenas.sh http://192.168.1.50/scripts/wrestic/wrestic-backup-to-truenas-local.sh sed -i "s/changemepls/$HOSTNAME/g" /home/akanealw/.config/wrestic/wrestic.toml sed -r 's/(resticbackups)(.*)/\1\L\2\E/g' /home/akanealw/.config/wrestic/wrestic.toml > /home/akanealw/.config/wrestic/wrestic2.toml mv /home/akanealw/.config/wrestic/wrestic.toml /home/akanealw/.config/wrestic/wresticbackup.toml diff --git a/wrestic/wrestic-backup-to-truenas-local.sh b/wrestic/wrestic-backup-to-truenas-local.sh index fda6b49..cba9c42 100644 --- a/wrestic/wrestic-backup-to-truenas-local.sh +++ b/wrestic/wrestic-backup-to-truenas-local.sh @@ -1,8 +1,13 @@ #!/bin/bash if ping -c 1 192.168.1.41 > /dev/null 2>&1 - then - sudo wrestic backup - else - echo "TrueNAS is offline" + then + if [[ -d /mnt/truenas-backups/archivebackups ]] + then + sudo wrestic backup + else + echo "TrueNAS is offline" + fi + else + echo "TrueNAS is offline" fi