-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (30 loc) · 836 Bytes
/
Copy pathmain.go
File metadata and controls
39 lines (30 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"context"
"os"
"os/signal"
"syscall"
"github.com/fvoci/hyper-backup/scheduler"
"github.com/fvoci/hyper-backup/utilities"
)
func main() {
if err := run(); err != nil {
utilities.Logger.Error(err)
os.Exit(1)
}
}
func run() error {
utilities.Logger.Info("[HyperBackup] ⏱️ Backup process starting")
if err := utilities.CheckConfig(); err != nil {
return err
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
schedule := os.Getenv("BACKUP_SCHEDULE")
interval := os.Getenv("BACKUP_INTERVAL_HOURS")
if schedule != "" && interval != "" {
utilities.Logger.Warn("[HyperBackup] ⚠️ Both BACKUP_SCHEDULE and BACKUP_INTERVAL_HOURS are set. Using BACKUP_SCHEDULE.")
}
scheduler.StartWithContext(ctx, schedule, interval)
return nil
}