mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 08:16:25 +00:00
custom restic binary
This commit is contained in:
parent
9256cdc38c
commit
88c6949208
@ -37,6 +37,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.autorestic.yml or ./.autorestic.yml)")
|
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.autorestic.yml or ./.autorestic.yml)")
|
||||||
rootCmd.PersistentFlags().BoolVar(&internal.CI, "ci", false, "CI mode disabled interactive mode and colors and enables verbosity")
|
rootCmd.PersistentFlags().BoolVar(&internal.CI, "ci", false, "CI mode disabled interactive mode and colors and enables verbosity")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&internal.VERBOSE, "verbose", "v", false, "verbose mode")
|
rootCmd.PersistentFlags().BoolVarP(&internal.VERBOSE, "verbose", "v", false, "verbose mode")
|
||||||
|
rootCmd.PersistentFlags().StringVar(&internal.RESTIC_BIN, "restic-bin", "restic", "specify custom restic binary")
|
||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,4 +27,12 @@ Verbose mode will show the output of the native restic commands that are otherwi
|
|||||||
autorestic --verbose backup -a
|
autorestic --verbose backup -a
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `--restic-bin`
|
||||||
|
|
||||||
|
With `--restic-bin` you can specify to run a specific restic binary. This can be useful if you want to [create a custom binary with root access that can be executed by any user](https://restic.readthedocs.io/en/stable/080_examples.html#full-backup-without-root).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
autorestic --restic-bin /some/path/to/my/custom/restic/binary
|
||||||
|
```
|
||||||
|
|
||||||
> :ToCPrevNext
|
> :ToCPrevNext
|
||||||
|
@ -129,7 +129,7 @@ func CheckConfig() error {
|
|||||||
return fmt.Errorf("config could not be loaded/found")
|
return fmt.Errorf("config could not be loaded/found")
|
||||||
}
|
}
|
||||||
if !CheckIfResticIsCallable() {
|
if !CheckIfResticIsCallable() {
|
||||||
return fmt.Errorf(`restic was not found. Install either with "autorestic install" or manually`)
|
return fmt.Errorf(`%s was not found. Install either with "autorestic install" or manually`, RESTIC_BIN)
|
||||||
}
|
}
|
||||||
for name, backend := range c.Backends {
|
for name, backend := range c.Backends {
|
||||||
backend.name = name
|
backend.name = name
|
||||||
|
@ -10,13 +10,15 @@ import (
|
|||||||
"github.com/cupcakearmy/autorestic/internal/colors"
|
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var RESTIC_BIN string
|
||||||
|
|
||||||
func CheckIfCommandIsCallable(cmd string) bool {
|
func CheckIfCommandIsCallable(cmd string) bool {
|
||||||
_, err := exec.LookPath(cmd)
|
_, err := exec.LookPath(cmd)
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckIfResticIsCallable() bool {
|
func CheckIfResticIsCallable() bool {
|
||||||
return CheckIfCommandIsCallable("restic")
|
return CheckIfCommandIsCallable(RESTIC_BIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExecuteOptions struct {
|
type ExecuteOptions struct {
|
||||||
@ -50,7 +52,7 @@ func ExecuteCommand(options ExecuteOptions, args ...string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExecuteResticCommand(options ExecuteOptions, args ...string) (string, error) {
|
func ExecuteResticCommand(options ExecuteOptions, args ...string) (string, error) {
|
||||||
options.Command = "restic"
|
options.Command = RESTIC_BIN
|
||||||
return ExecuteCommand(options, args...)
|
return ExecuteCommand(options, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user