Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Hendrik Schutter | dbb15d84b5 | |
Hendrik Schutter | a6f933c5d5 | |
Hendrik Schutter | 1ad6d2bab1 | |
Hendrik Schutter | 8b31476644 | |
Hendrik Schutter | 988ec97833 |
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Check AutoBackup
|
||||||
|
After=syslog.target network.target
|
||||||
|
[Service]
|
||||||
|
RestartSec=2s
|
||||||
|
Type=oneshot
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
ExecStart=/root/check_AutoBackup.sh
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,7 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Check AutoBackup Timer
|
||||||
|
[Timer]
|
||||||
|
Persistent=false
|
||||||
|
OnCalendar=*-*-* 2,8,14,20:05:00
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
36
README.md
36
README.md
|
@ -14,7 +14,7 @@ The script monitors the backend of a restic backup. The bash script is executed
|
||||||
* no restic authentication needed
|
* no restic authentication needed
|
||||||
* multiple repos
|
* multiple repos
|
||||||
* individual interval for each repo
|
* individual interval for each repo
|
||||||
* custom email server via [ssmtp](https://wiki.debian.org/sSMTP)
|
* 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)
|
* loud alarm buzzer via [FTDI_simple_alarm](https://git.mosad.xyz/localhorst/FTDI_simple_alarm)
|
||||||
|
|
||||||
## Planned Features
|
## Planned Features
|
||||||
|
@ -23,22 +23,9 @@ The script monitors the backend of a restic backup. The bash script is executed
|
||||||
## Installation
|
## Installation
|
||||||
#### 1. download the check_AutoBackup.sh
|
#### 1. download the check_AutoBackup.sh
|
||||||
#### 2. chmod +x check_AutoBackup.sh
|
#### 2. chmod +x check_AutoBackup.sh
|
||||||
#### 3. install ssmtp
|
#### 3. install mailsend
|
||||||
#### 4. nano /etc/ssmtp/ssmtp.conf
|
|
||||||
|
|
||||||
```UseSTARTTLS=YES
|
#### 4. edit settings in check_AutoBackup.sh
|
||||||
FromLineOverride=YES
|
|
||||||
root=
|
|
||||||
mailhub=mail.yourmailserver.tld:587
|
|
||||||
AuthUser=mailuser@maildomain.tld
|
|
||||||
AuthPass=yourmailuserpassword
|
|
||||||
```
|
|
||||||
#### 5. nano /etc/ssmtp/revaliases
|
|
||||||
```
|
|
||||||
root:mailuser@maildomain.tld:mail.yourmailserver.tld:587
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 6. edit settings in check_AutoBackup.sh
|
|
||||||
|
|
||||||
```
|
```
|
||||||
DEBUG="true" #true --> dont send email
|
DEBUG="true" #true --> dont send email
|
||||||
|
@ -47,10 +34,9 @@ backupFolder="./backups" #directory that contains all repos
|
||||||
|
|
||||||
receiverEmail="mailuser@maildomain.tld"
|
receiverEmail="mailuser@maildomain.tld"
|
||||||
senderEmail="mailuser@maildomain.tld"
|
senderEmail="mailuser@maildomain.tld"
|
||||||
senderName="AutoBackup Watchdog"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 7. edit repo settings in check_AutoBackup.sh
|
#### 5. edit repo settings in check_AutoBackup.sh
|
||||||
|
|
||||||
```
|
```
|
||||||
repos_name[0]=" first backup repo"
|
repos_name[0]=" first backup repo"
|
||||||
|
@ -58,10 +44,18 @@ repos_directory[0]="first_repo" #repo in backupFolder
|
||||||
repos_interval[0]=21600 #sec
|
repos_interval[0]=21600 #sec
|
||||||
repos_interval_tolerance[0]=10 #%
|
repos_interval_tolerance[0]=10 #%
|
||||||
```
|
```
|
||||||
#### 8. install crontab or systemd-timer
|
#### 6. install crontab or systemd-timer
|
||||||
|
For systemd see
|
||||||
|
`CheckAutoBackup.service` and `CheckAutoBackup.timer`
|
||||||
|
|
||||||
#### 9. optional install FTDI simple alarm
|
For corntab see
|
||||||
|
|
||||||
|
```
|
||||||
|
5 2,8,14,20 * * * /root/check_AutoBackup.sh >/dev/null 2>&
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 7. optional install FTDI simple alarm
|
||||||
|
|
||||||
[FTDI_simple_alarm](https://git.mosad.xyz/localhorst/FTDI_simple_alarm)
|
[FTDI_simple_alarm](https://git.mosad.xyz/localhorst/FTDI_simple_alarm)
|
||||||
|
|
||||||
uncomment line 117 in check_AutoBackup.sh
|
uncomment line 167 in check_AutoBackup.sh
|
||||||
|
|
|
@ -1,29 +1,31 @@
|
||||||
#! /bin/bash
|
-#! /bin/bash
|
||||||
|
|
||||||
### GENERAL SETTINGS ###
|
### GENERAL SETTINGS ###
|
||||||
DEBUG="true"
|
DEBUG="false" #don't send mail if in debug mode
|
||||||
timestampFolder="index" #folder for reading timestamp
|
timestampFolder="index" #folder for reading timestamp
|
||||||
backupFolder="./backups" #directory that contains all repos
|
backupFolder="/mnt/hdd/backups/" #directory that contains all repos
|
||||||
|
backupServerName="Onsite Backup" #name of this backup server
|
||||||
########################
|
########################
|
||||||
### eMail ###
|
### eMail ###
|
||||||
receiverEmail="admin@coptersicht.de"
|
receiverEmail="dummy@gmail.com"
|
||||||
senderEmail="autobackupwatchdog@coptersicht.de"
|
senderEmail="dummy@gmail.com"
|
||||||
senderName="AutoBackup Watchdog"
|
senderPassword="__PW_DB__"
|
||||||
|
mailServer="dummy@gmail.com"
|
||||||
########################
|
########################
|
||||||
|
|
||||||
######### REPO SETTINGS #########
|
######### REPO SETTINGS #########
|
||||||
|
|
||||||
repos_name[0]=" first backup repo"
|
repos_name[0]="CDS Backup"
|
||||||
repos_directory[0]="first_repo"
|
repos_directory[0]="cdsbackup"
|
||||||
repos_interval[0]=21600 #sec
|
repos_interval[0]=21600 #sec
|
||||||
repos_interval_tolerance[0]=10 #%
|
repos_interval_tolerance[0]=10 #%
|
||||||
|
|
||||||
#repos_name[1]="second backup repo"
|
#repos_name[1]="SDS Backup"
|
||||||
#repos_directory[1]="second_repo"
|
#repos_directory[1]="sdsbackup"
|
||||||
#repos_interval[1]=21600 #sec
|
#repos_interval[1]=21600 #sec
|
||||||
#repos_interval_tolerance[1]=10 #%
|
#repos_interval_tolerance[1]=10 #%
|
||||||
|
|
||||||
#repos_name[2]=" another backup repo"
|
#repos_name[2]="another backup repo"
|
||||||
#repos_directory[2]="another_repo"
|
#repos_directory[2]="another_repo"
|
||||||
#repos_interval[2]=21600 #sec
|
#repos_interval[2]=21600 #sec
|
||||||
#repos_interval_tolerance[2]=10 #%
|
#repos_interval_tolerance[2]=10 #%
|
||||||
|
@ -55,9 +57,6 @@ do
|
||||||
echo "Repo ${repos_directory[i]} doesnt exist!"
|
echo "Repo ${repos_directory[i]} doesnt exist!"
|
||||||
rm -f mail_content.txt
|
rm -f mail_content.txt
|
||||||
cat >> mail_content.txt <<EOL
|
cat >> mail_content.txt <<EOL
|
||||||
Subject: AutoBackup Failure "${repos_name[i]}"
|
|
||||||
From: $senderEmail
|
|
||||||
Content-Type: text/html; charset="utf8
|
|
||||||
<head>
|
<head>
|
||||||
<style>
|
<style>
|
||||||
h1{
|
h1{
|
||||||
|
@ -83,7 +82,7 @@ Content-Type: text/html; charset="utf8
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>AutoBackup Failure</h1>
|
<h1>AutoBackup Failure on $backupServerName</h1>
|
||||||
<h2>Directory for the automatic backup for "${repos_name[i]}" not found</h2>
|
<h2>Directory for the automatic backup for "${repos_name[i]}" not found</h2>
|
||||||
<div>
|
<div>
|
||||||
<p>Local time: $(date)</p>
|
<p>Local time: $(date)</p>
|
||||||
|
@ -91,14 +90,14 @@ Content-Type: text/html; charset="utf8
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<footer>
|
<footer>
|
||||||
<p>Version: 0.2</p>
|
<p>Version: 0.2.3</p>
|
||||||
<p>Author: <a href="mailto:hendrik.schutter@coptersicht.de">hendrik.schutter@coptersicht.de</a></p>
|
<p>Author: <a href="mailto:mail@hendrikschutter.com">mail@hendrikschutter.com</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
EOL
|
EOL
|
||||||
if [ "$DEBUG" = "false" ];
|
if [ "$DEBUG" = "false" ];
|
||||||
then
|
then
|
||||||
ssmtp -f$senderEmail -F$senderName $receiverEmail < 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
|
rm mail_content.txt
|
||||||
#/etc/init.d/alarm start
|
#/etc/init.d/alarm start
|
||||||
fi
|
fi
|
||||||
|
@ -122,9 +121,6 @@ EOL
|
||||||
echo -e "\e[39m " #reset console color to black
|
echo -e "\e[39m " #reset console color to black
|
||||||
rm -f mail_content.txt
|
rm -f mail_content.txt
|
||||||
cat >> mail_content.txt <<EOL
|
cat >> mail_content.txt <<EOL
|
||||||
Subject: AutoBackup Failure "${repos_name[i]}"
|
|
||||||
From: $senderEmail
|
|
||||||
Content-Type: text/html; charset="utf8
|
|
||||||
<head>
|
<head>
|
||||||
<style>
|
<style>
|
||||||
h1{
|
h1{
|
||||||
|
@ -150,7 +146,7 @@ Content-Type: text/html; charset="utf8
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>AutoBackup Failure</h1>
|
<h1>AutoBackup Failure on $backupServerName</h1>
|
||||||
<h2>Overdue for the automatic backup for "${repos_name[i]}"</h2>
|
<h2>Overdue for the automatic backup for "${repos_name[i]}"</h2>
|
||||||
<div>
|
<div>
|
||||||
<p>Local time: $(date)</p>
|
<p>Local time: $(date)</p>
|
||||||
|
@ -161,18 +157,18 @@ Content-Type: text/html; charset="utf8
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<footer>
|
<footer>
|
||||||
<p>Version: 0.2</p>
|
<p>Version: 0.2.3</p>
|
||||||
<p>Author: <a href="mailto:hendrik.schutter@coptersicht.de">hendrik.schutter@coptersicht.de</a></p>
|
<p>Author: <a href="mailto:mail@hendrikschutter.com">mail@hendrikschutter.com</a></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
EOL
|
EOL
|
||||||
if [ "$DEBUG" = "false" ];
|
if [ "$DEBUG" = "false" ];
|
||||||
then
|
then
|
||||||
ssmtp -f$senderEmail -F$senderName $receiverEmail < 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
|
rm mail_content.txt
|
||||||
#/etc/init.d/alarm start
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo " "
|
echo " "
|
||||||
echo "Finished"
|
echo "Finished"
|
||||||
|
|
Loading…
Reference in New Issue