diff --git a/README.rst b/README.rst index 15ef817..f11ea5a 100644 --- a/README.rst +++ b/README.rst @@ -220,6 +220,9 @@ check read_data_percentage An integer value between 0 and 100. Specifies the percentage of randomly choosen data in the repository that is checked for modifications on each run of check. If 100% is not an integer multiple of the given percentage the given percentage will be adjusted accordingly. E.g. a percentage of 50% will check half of the repository on each check while a percentage of 43% will only check 33% of the repository on each check. +custom_flags + String array of custom flags that are not directly supported e.g. ``--ignore-inode``. All flags are directly passed to restic. Unsupported flags might break restic backups. + handler Handlers are called at specific events during execution. They may be used to run custom scripts e.g. to notify the user about a successful check of the repository. diff --git a/cmd/shell.go b/cmd/shell.go index 21e4be5..b41221c 100644 --- a/cmd/shell.go +++ b/cmd/shell.go @@ -34,7 +34,7 @@ var shellCmd = &cobra.Command{ os.Exit(1) } - c := restic.PrepareResticEnvironmentCommand(shell, repository.URL, repository.Password, repository.Environment, 0, 0) + c := restic.PrepareResticEnvironmentCommand(shell, repository.URL, repository.Password, repository.Environment, 0, 0, []string{}) c.Stdin = os.Stdin c.Stdout = os.Stdout c.Stderr = os.Stderr diff --git a/cmd/version.go b/cmd/version.go index 28e9ca0..5e47f39 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -17,6 +17,6 @@ var versionCmd = &cobra.Command{ Short: "Print the version number", Long: `Print the version number"`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("rester v0.1.1 -- " + versionRevision) + fmt.Println("rester v0.1.2 -- " + versionRevision) }, } diff --git a/debian/changelog b/debian/changelog index 43e92ed..f6b48ca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +rester (0.1.2-1) unstable; urgency=medium + + * Update to 0.1.2. + + -- root Thu, 3 Dec 2018 20:00:00 +0000 + + rester (0.1.1-1) unstable; urgency=medium * Initial release. diff --git a/internal/config.go b/internal/config.go index ab8c938..256b5f2 100644 --- a/internal/config.go +++ b/internal/config.go @@ -47,6 +47,7 @@ type Repository struct { Password string `json:"password,omitempty"` Environment map[string]string `json:"environment,omitempty"` Check Check `json:"check,omitempty"` + CustomFlags []string `json:"custom_flags,omitempty"` repositoryDefaultable } diff --git a/internal/config_test.go b/internal/config_test.go index fe4d85f..b8ec23e 100644 --- a/internal/config_test.go +++ b/internal/config_test.go @@ -28,7 +28,8 @@ func TestLoadConfig(t *testing.T) { }, "check": { "read_data_percentage": 5 - } + }, + "custom_flags": [ "-o", "key=value" ] } ], "backups": [ @@ -87,6 +88,9 @@ func TestLoadConfig(t *testing.T) { assert.Equal(t, "/home/test/repos/test2", config.Repositories[1].URL) assert.Equal(t, "2", config.Repositories[1].Password) assert.Equal(t, uint(5), config.Repositories[1].Check.ReadDataPercentage) + assert.Equal(t, 2, len(config.Repositories[1].CustomFlags), "invalid custom flag") + assert.Equal(t, "-o", config.Repositories[1].CustomFlags[0]) + assert.Equal(t, "key=value", config.Repositories[1].CustomFlags[1]) assert.Equal(t, "notify_send -t 1000 check done", config.Repositories[1].Handler.CheckSuccess) assert.Equal(t, "notify_send check failed", config.Repositories[1].Handler.CheckFailure) assert.Equal(t, "notify_send -t 1000 forget done", config.Repositories[1].Handler.ForgetSuccess) diff --git a/internal/restic.go b/internal/restic.go index 5681750..71659ae 100644 --- a/internal/restic.go +++ b/internal/restic.go @@ -461,13 +461,13 @@ func (r Restic) prepareResticCommand( environment := combineMaps(repo.Environment, additionalEnvironment) return r.PrepareResticEnvironmentCommand( r.resticExecutable, repo.URL, repo.Password, environment, - repo.LimitDownload, repo.LimitUpload, + repo.LimitDownload, repo.LimitUpload, repo.CustomFlags, ) } func (r Restic) PrepareResticEnvironmentCommand( command string, repoURL string, password string, environment map[string]string, - limitDownload int, limitUpload int, + limitDownload int, limitUpload int, customFlags []string, ) *exec.Cmd { cmd := exec.Command(command) @@ -478,6 +478,10 @@ func (r Restic) PrepareResticEnvironmentCommand( cmd.Args = append(cmd.Args, "--limit-upload", strconv.Itoa(limitUpload)) } + for _, flag := range customFlags { + cmd.Args = append(cmd.Args, flag) + } + cmd.Env = append( os.Environ(), convertEnvironment(environment)...,