35 lines
1,020 B
Go
35 lines
1,020 B
Go
package prune
|
|
|
|
import (
|
|
"os/exec"
|
|
"fmt"
|
|
"git.jcg.re/jcgruenhage/borgocli/run/config"
|
|
)
|
|
|
|
func Run(config config.Config) {
|
|
var parameters []string
|
|
|
|
parameters = append(parameters, "prune")
|
|
|
|
if len(config.Retention.Within) != 0 {
|
|
parameters = append(parameters, fmt.Sprintf("--keep-within %s", config.Retention.Within))
|
|
}
|
|
|
|
parameters = append(parameters, fmt.Sprintf("--keep-hourly %d", config.Retention.Hourly))
|
|
parameters = append(parameters, fmt.Sprintf("--keep-daily %d", config.Retention.Daily))
|
|
parameters = append(parameters, fmt.Sprintf("--keep-weekly %d", config.Retention.Weekly))
|
|
parameters = append(parameters, fmt.Sprintf("--keep-monthly %d", config.Retention.Monthly))
|
|
parameters = append(parameters, fmt.Sprintf("--keep-yearly %d", config.Retention.Yearly))
|
|
|
|
parameters = append(parameters, fmt.Sprintf("-P %s", config.Data.Hostname), config.Data.Repository)
|
|
|
|
cmd := exec.Command("borg", parameters...)
|
|
|
|
|
|
fmt.Print(cmd.Path, parameters)
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|