updated to mailsend-go

This commit is contained in:
Hendrik Schutter 2022-09-01 11:33:56 +02:00
parent a6f933c5d5
commit dbb15d84b5
2 changed files with 20 additions and 19 deletions

View File

@ -14,7 +14,7 @@ The script monitors the backend of a restic backup. The bash script is executed
* no restic authentication needed
* multiple repos
* individual interval for each repo
* custom email server via [mailsend](https://github.com/muquit/mailsend/blob/master/doc/examples.mediawiki)
* custom email server via [mailsend](https://github.com/muquit/mailsend-go/releases)
* loud alarm buzzer via [FTDI_simple_alarm](https://git.mosad.xyz/localhorst/FTDI_simple_alarm)
## Planned Features

View File

@ -1,27 +1,29 @@
#! /bin/bash
-#! /bin/bash
### GENERAL SETTINGS ###
DEBUG="true" #don't send mail if in debug mode
DEBUG="false" #don't send mail if in debug mode
timestampFolder="index" #folder for reading timestamp
backupFolder="/mnt/hdd/backups/" #directory that contains all repos
backupServerName="Onsite Backup" #name of this backup server
########################
### eMail ###
receiverEmail="localhorst@mosad.xyz"
senderEmail="______________@mosad.xyz"
receiverEmail="dummy@gmail.com"
senderEmail="dummy@gmail.com"
senderPassword="__PW_DB__"
mailServer="dummy@gmail.com"
########################
######### REPO SETTINGS #########
repos_name[0]="Name"
repos_directory[0]="path"
repos_name[0]="CDS Backup"
repos_directory[0]="cdsbackup"
repos_interval[0]=21600 #sec
repos_interval_tolerance[0]=10 #%
#repos_name[1]="another backup repo"
#repos_directory[1]="another_repo"
#repos_name[1]="SDS Backup"
#repos_directory[1]="sdsbackup"
#repos_interval[1]=21600 #sec
#repos_interval_tolerance[1]=10 #%
#################################
#repos_name[2]="another backup repo"
#repos_directory[2]="another_repo"
@ -80,7 +82,7 @@ do
</style>
</head>
<body>
<h1>AutoBackup Failure</h1>
<h1>AutoBackup Failure on $backupServerName</h1>
<h2>Directory for the automatic backup for "${repos_name[i]}" not found</h2>
<div>
<p>Local time: $(date)</p>
@ -88,14 +90,14 @@ do
</div>
</body>
<footer>
<p>Version: 0.2.2</p>
<p>Author: <a href="mailto:localhorst@mosad.xyz">localhorst@mosad.xyz</a></p>
<p>Version: 0.2.3</p>
<p>Author: <a href="mailto:mail@hendrikschutter.com">mail@hendrikschutter.com</a></p>
</footer>
EOL
if [ "$DEBUG" = "false" ];
then
mailsend -f $senderEmail -t $receiverEmail -sub "AutoBackup Failure ${repos_name[i]}" -smtp mail.emailserver.science -port 587 -starttls -auth -user autobackupwatchdog@mosad.xyz -pass "__PW_DB__" -cs "utf-8" -mime-type "text/html" -msg-body "mail_content.txt"
mailsend-go -sub "AutoBackup Failure ${repos_name[i]} on $backupServerName" -smtp $mailServer -port 587 auth -user $senderEmail -pass $senderPassword -from $senderEmail -to $receiverEmail body -file mail_content.txt
rm mail_content.txt
#/etc/init.d/alarm start
fi
@ -144,7 +146,7 @@ EOL
</style>
</head>
<body>
<h1>AutoBackup Failure</h1>
<h1>AutoBackup Failure on $backupServerName</h1>
<h2>Overdue for the automatic backup for "${repos_name[i]}"</h2>
<div>
<p>Local time: $(date)</p>
@ -155,16 +157,15 @@ EOL
</div>
</body>
<footer>
<p>Version: 0.2.2</p>
<p>Author: <a href="mailto:localhorst@mosad.xyz">localhorst@mosad.xyz</a></p>
<p>Version: 0.2.3</p>
<p>Author: <a href="mailto:mail@hendrikschutter.com">mail@hendrikschutter.com</a></p>
</footer>
EOL
if [ "$DEBUG" = "false" ];
then
mailsend -f $senderEmail -t $receiverEmail -sub "AutoBackup Failure ${repos_name[i]}" -smtp mail.emailserver.science -port 587 -starttls -auth -user autobackupwatchdog@mosad.xyz -pass "__PW_DB__" -cs "utf-8" -mime-type "text/html" -msg-body "mail_content.txt"
mailsend-go -sub "AutoBackup Failure ${repos_name[i]} on $backupServerName" -smtp $mailServer -port 587 auth -user $senderEmail -pass $senderPassword -from $senderEmail -to $receiverEmail body -file mail_content.txt
rm mail_content.txt
#/etc/init.d/alarm start
fi
fi
done