added check if backup dir exists

This commit is contained in:
Hendrik Schutter 2020-12-13 09:49:21 +01:00
parent e71081da0b
commit ae030c026a
1 changed files with 58 additions and 2 deletions

View File

@ -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 <<EOL
Subject: AutoBackup Failure "${repos_name[i]}"
From: $senderEmail
Content-Type: text/html; charset="utf8
<head>
<style>
h1{
text-align: center;
font-size: 60;
color: red;
margin: 30px;
}
h2{
font-size: 30;
color: black;
}
div {
margin: 30px;
font-family: "Lucida Console", Courier, monospace;
}
.overdue{
color: red;
}
footer{
margin-top: 9em;
}
</style>
</head>
<body>
<h1>AutoBackup Failure</h1>
<h2>Directory for the automatic backup for "${repos_name[i]}" not found</h2>
<div>
<p>Local time: $(date)</p>
<p>Failed backup repo: ${repos_name[i]}</p>
</div>
</body>
<footer>
<p>Version: 0.2</p>
<p>Author: <a href="mailto:hendrik.schutter@coptersicht.de">hendrik.schutter@coptersicht.de</a></p>
</footer>
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
</div>
</body>
<footer>
<p>Version: 0.1</p>
<p>Version: 0.2</p>
<p>Author: <a href="mailto:hendrik.schutter@coptersicht.de">hendrik.schutter@coptersicht.de</a></p>
</footer>