parse job definitions from YAML file

This commit is contained in:
Sam Hoffman
2026-01-30 19:16:00 -05:00
parent b14132886d
commit 5ea252ecb7
7 changed files with 94 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
"log"
"git.gentoo.party/sam/thanks/internal/jobs"
)
@@ -13,10 +14,14 @@ var (
BuildTime = "unknown"
)
var flagVersion = false
var (
flagVersion = false
jobsFile = "thanks.yaml"
)
func init() {
flag.BoolVar(&flagVersion, "v", false, "show program version")
flag.StringVar(&jobsFile, "jobs", "thanks.yaml", "backup job definitions file")
}
func main() {
@@ -27,15 +32,15 @@ func main() {
return
}
myJob := jobs.BackupJob{
Source: "zroot/home/sam/thanks",
Target: "zrust/backup/weller/thanks",
TargetHost: "backup@woodford.gentoo.party",
Keep: 30,
Prefix: "thanks-",
Recursive: false,
backupJobs, err := jobs.ParseFile(jobsFile)
if err != nil {
log.Fatalf("error reading backup job definitions: %s\n", err.Error())
}
ctx := context.Background()
myJob.Do(ctx)
for _, myJob := range backupJobs {
myJob.Do(ctx)
}
log.Printf("backups completed successfully")
}