From 32259a0a6a5822b7e67d3953cb869a5a2124f24b Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 23 May 2016 11:59:23 +0200 Subject: [PATCH] Do backup removes only after certain commands --- configfile.go | 4 ++++ main.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configfile.go b/configfile.go index 7c9155d..4fba976 100644 --- a/configfile.go +++ b/configfile.go @@ -27,6 +27,10 @@ var ( commandBackup, commandRemove, } + removeCommands = []string{ + commandBackup, + commandCleanup, + } ) type configFile struct { diff --git a/main.go b/main.go index 5acd6f4..d8d82d0 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/Luzifer/go_helpers/str" "github.com/Luzifer/go_helpers/which" "github.com/Luzifer/rconfig" "github.com/mitchellh/go-homedir" @@ -117,7 +118,7 @@ func main() { return } - if config.Cleanup.Type != "none" { + if config.Cleanup.Type != "none" && str.StringInSlice(argv[1], removeCommands) { logf("++++ Starting removal of old backups") if err := execute(config, []string{commandRemove}); err != nil {