From b9bbbe7d55e8147bfa5fc23c159abd63a4b27696 Mon Sep 17 00:00:00 2001 From: Antoine Lima Date: Fri, 17 Mar 2023 00:01:01 +0000 Subject: [PATCH] Improved cron/forget scripts --- runcron | 10 +++++----- runforget | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runcron b/runcron index 74303cd..c7401cd 100755 --- a/runcron +++ b/runcron @@ -1,13 +1,13 @@ #! /usr/bin/env bash -autorestic -c /etc/autorestic/.autorestic.yml --ci cron --lean 1> /tmp/autorestic.log 2>/tmp/autorestic-err.log +autorestic -c /etc/autorestic/.autorestic.yml --ci cron 1> /tmp/autorestic.log 2>/tmp/autorestic-err.log ret=$? -if [ "$ret" != 0 ] || [ -s /tmp/autorestic-err.log ] +if [[ "$ret" != 0 || -s /tmp/autorestic-err.log ]] then - cat <(echo -e "Command failed with return code $ret and log:") /tmp/autorestic-err.log | mail -s "Autorestic Backup: Failed" root + cat <(echo "Command failed with return code $ret and log:") /tmp/tmp/autorestic-err.log <(echo "===============") /tmp/autorestic.log | mail -s "Autorestic Backup: Failed" root else - if [ $(wc -l < /tmp/autorestic.log) -gt 3 ] + if [[ $(wc -l < /tmp/autorestic.log) -gt 15 ]] then - cat <(echo -e "Command successfully finished with the following log:") /tmp/autorestic.log | mail -s "Autorestic Backup: Success" root + cat <(echo -e "Command successfully finished with the following log:") /tmp/tmp/autorestic-err.log <(echo "===============") /tmp/autorestic.log | mail -s "Autorestic Backup: Success" root fi fi diff --git a/runforget b/runforget index be50f25..166a0b1 100755 --- a/runforget +++ b/runforget @@ -2,9 +2,9 @@ autorestic -c /etc/autorestic/.autorestic.yml --ci forget --all --prune 1> /tmp/autorestic-prune.log 2>/tmp/autorestic-prune-err.log ret=$? -if [ "$ret" != 0 ] || [ -s /tmp/autorestic-prune-err.log ] +if [[ "$ret" != 0 || -s /tmp/autorestic-prune-err.log ]] then - cat <(echo -e "Command failed with return code $ret and log:") /tmp/autorestic-prune-err.log | mail -s "Autorestic Pruning: Failed" root + cat <(echo "Command failed with return code $ret and log:") /tmp/autorestic-prune-err.log <(echo "===============") /tmp/autorestic-prune.log | mail -s "Autorestic Pruning: Failed" root else - cat <(echo -e "Command successfully finished with the following log:") /tmp/autorestic-prune.log | mail -s "Autorestic Pruning: Success" root + cat <(echo "Command successfully finished with the following log:") /tmp/autorestic-prune.log | mail -s "Autorestic Pruning: Success" root fi