test email and clean first snapshots

This commit is contained in:
shoopea
2022-06-17 20:54:14 +08:00
parent 41d56eb90a
commit e62627e406
5 changed files with 88 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"time"
)
var (
@@ -15,6 +16,7 @@ var (
testFlag = flag.Bool("test", false, "test run")
debugFlag = flag.Bool("debug", false, "debug")
cfg Config
email *Email
)
func main() {
@@ -22,6 +24,9 @@ func main() {
fmt.Printf("backup (%s)\n", version)
email = new(Email)
email.startTime = time.Now()
err := cfg.Load()
if err != nil {
log.Printf("Cannot load config (%s)", err)
@@ -33,6 +38,10 @@ func main() {
log.Printf("Cannot run schedule (%s)", err)
os.Exit(1)
}
if len(email.items) > 0 {
SendMail(cfg.Email.smtpHost, cfg.Email.fromEmail, "Autobackup report", fmt.Sprintf("%v", email.items), cfg.Email.toEmail)
}
}
//RunBackup run all backup targets where schedule is registered