From ae030c026a191e5c6de31d65152680a16eb212d5 Mon Sep 17 00:00:00 2001 From: Hendrik Schutter Date: Sun, 13 Dec 2020 09:49:21 +0100 Subject: [PATCH] added check if backup dir exists --- ...k_AutoBackup.sh => cleacheck_AutoBackup.sh | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) rename check_AutoBackup.sh => cleacheck_AutoBackup.sh (72%) diff --git a/check_AutoBackup.sh b/cleacheck_AutoBackup.sh similarity index 72% rename from check_AutoBackup.sh rename to cleacheck_AutoBackup.sh index 8207013..7b2952a 100644 --- a/check_AutoBackup.sh +++ b/cleacheck_AutoBackup.sh @@ -46,7 +46,63 @@ for i in $(eval echo "{0..$repo_count}") #loop through all repos do echo " " echo "Checking repo: ${repos_name[i]}" - cd ${repos_directory[i]} #jump into repo + + if [ -d "$DIR" ]; then + # Take action if ${repos_directory[i]} exists ### + cd ${repos_directory[i]} #jump into repo + else + # Repo doesnt exist + echo "Repo ${repos_directory[i]} doesnt exist!" + rm -f mail_content.txt + cat >> mail_content.txt < + + +

AutoBackup Failure

+

Directory for the automatic backup for "${repos_name[i]}" not found

+
+

Local time: $(date)

+

Failed backup repo: ${repos_name[i]}

+
+ + + +EOL + if [ "$DEBUG" = "false" ]; + then + ssmtp -f$senderEmail -F$senderName $receiverEmail < mail_content.txt + rm mail_content.txt + #/etc/init.d/alarm start + fi + fi timestamp=$(date -r "$timestampFolder" +%s) #get timestap of last backup aka the "index" folder time=$(date +%s) #get local time diff=$(($time-$timestamp)) #compute diff time @@ -105,7 +161,7 @@ Content-Type: text/html; charset="utf8