diff --git a/build/build.go b/build/build.go index 81eaecb..8bf4fd6 100644 --- a/build/build.go +++ b/build/build.go @@ -17,11 +17,14 @@ import ( var DIR, _ = filepath.Abs("./dist") var targets = map[string][]string{ + // "aix": {"ppc64"}, // Not supported by fsnotify "darwin": {"amd64", "arm64"}, "freebsd": {"386", "amd64", "arm"}, - "linux": {"386", "amd64", "arm", "arm64"}, + "linux": {"386", "amd64", "arm", "arm64", "ppc64le", "mips", "mipsle", "mips64", "mips64le", "s390x"}, "netbsd": {"386", "amd64"}, "openbsd": {"386", "amd64"}, + // "windows": {"386", "amd64"}, // Not supported by autorestic + "solaris": {"amd64"}, } type buildOptions struct { diff --git a/cmd/root.go b/cmd/root.go index a9ea49b..0433ec1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -41,6 +41,7 @@ func init() { rootCmd.PersistentFlags().BoolVar(&flags.CI, "ci", false, "CI mode disabled interactive mode and colors and enables verbosity") rootCmd.PersistentFlags().BoolVarP(&flags.VERBOSE, "verbose", "v", false, "verbose mode") rootCmd.PersistentFlags().StringVar(&flags.RESTIC_BIN, "restic-bin", "restic", "specify custom restic binary") + rootCmd.PersistentFlags().StringVar(&flags.DOCKER_IMAGE, "docker-image", "cupcakearmy/autorestic:"+internal.VERSION, "specify a custom docker image") cobra.OnInitialize(initConfig) } diff --git a/docs/markdown/community.md b/docs/markdown/community.md index 7292e4d..a70bd3e 100644 --- a/docs/markdown/community.md +++ b/docs/markdown/community.md @@ -8,5 +8,6 @@ A list of community driven projects. (No official affiliation) - Ansible Role: - Ansible Role: - Ansible Role: +- Ansible Role: > :ToCPrevNext diff --git a/docs/markdown/installation.md b/docs/markdown/installation.md index e932d44..6fa8230 100644 --- a/docs/markdown/installation.md +++ b/docs/markdown/installation.md @@ -5,7 +5,7 @@ Linux & macOS. Windows is not supported. If you have problems installing please Autorestic requires `bash`, `wget` and `bzip2` to be installed. For most systems these should be already installed. ```bash -wget -qO - https://raw.githubusercontent.com/CupCakeArmy/autorestic/master/install.sh | bash +wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash ``` ## Alternatives diff --git a/docs/markdown/location/forget.md b/docs/markdown/location/forget.md index 37e6e8f..530b499 100644 --- a/docs/markdown/location/forget.md +++ b/docs/markdown/location/forget.md @@ -21,7 +21,7 @@ locations: keep-weekly: 1 # keep 1 last weekly snapshots keep-monthly: 12 # keep 12 last monthly snapshots keep-yearly: 7 # keep 7 last yearly snapshots - keep-within: '2w' # keep snapshots from the last 2 weeks + keep-within: '14d' # keep snapshots from the last 14 days ``` ## Globally diff --git a/docs/markdown/quick.md b/docs/markdown/quick.md index 37e776e..4aa2a31 100644 --- a/docs/markdown/quick.md +++ b/docs/markdown/quick.md @@ -3,7 +3,7 @@ ## Installation ```bash -wget -qO - https://raw.githubusercontent.com/CupCakeArmy/autorestic/master/install.sh | bash +wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash ``` See [installation](/installation) for alternative options. diff --git a/install.sh b/install.sh index 2638498..57600bc 100755 --- a/install.sh +++ b/install.sh @@ -31,6 +31,11 @@ else fi echo $ARCH +if ! command -v bzip2 &>/dev/null; then + echo "Missing bzip2 command. Please install the bzip2 package for your system." + exit 1 +fi + wget -qO - https://api.github.com/repos/cupcakearmy/autorestic/releases/latest \ | grep "browser_download_url.*_${OS}_${ARCH}" \ | cut -d : -f 2,3 \ diff --git a/internal/backend.go b/internal/backend.go index 40bb9d6..0a3c177 100644 --- a/internal/backend.go +++ b/internal/backend.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/cupcakearmy/autorestic/internal/colors" + "github.com/cupcakearmy/autorestic/internal/flags" ) type BackendRest struct { @@ -121,13 +122,17 @@ func (b Backend) validate() error { } options := ExecuteOptions{Envs: env, Silent: true} // Check if already initialized - _, _, err = ExecuteResticCommand(options, "check") + cmd := []string{"check"} + cmd = append(cmd, combineBackendOptions("check", b)...) + _, _, err = ExecuteResticCommand(options, cmd...) if err == nil { return nil } else { // If not initialize colors.Body.Printf("Initializing backend \"%s\"...\n", b.name) - _, _, err := ExecuteResticCommand(options, "init") + cmd := []string{"init"} + cmd = append(cmd, combineBackendOptions("init", b)...) + _, _, err := ExecuteResticCommand(options, cmd...) return err } } @@ -160,7 +165,6 @@ func (b Backend) ExecDocker(l Location, args []string) (int, string, error) { args = append([]string{"restic"}, args...) docker := []string{ "run", "--rm", - "--pull", "always", "--entrypoint", "ash", "--workdir", dir, "--volume", volume + ":" + dir, @@ -194,6 +198,7 @@ func (b Backend) ExecDocker(l Location, args []string) (int, string, error) { for key, value := range env { docker = append(docker, "--env", key+"="+value) } - docker = append(docker, "cupcakearmy/autorestic:"+VERSION, "-c", strings.Join(args, " ")) + + docker = append(docker, flags.DOCKER_IMAGE, "-c", strings.Join(args, " ")) return ExecuteCommand(options, docker...) } diff --git a/internal/config.go b/internal/config.go index 70f3dca..a0bbf2f 100644 --- a/internal/config.go +++ b/internal/config.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/viper" ) -const VERSION = "1.7.2" +const VERSION = "1.7.4" type OptionMap map[string][]interface{} type Options map[string]OptionMap @@ -303,7 +303,17 @@ func getOptions(options Options, keys []string) []string { return selected } -func combineOptions(key string, l Location, b Backend) []string { +func combineBackendOptions(key string, b Backend) []string { + // Priority: backend > global + var options []string + gFlags := getOptions(GetConfig().Global, []string{key}) + bFlags := getOptions(b.Options, []string{"all", key}) + options = append(options, gFlags...) + options = append(options, bFlags...) + return options +} + +func combineAllOptions(key string, l Location, b Backend) []string { // Priority: location > backend > global var options []string gFlags := getOptions(GetConfig().Global, []string{key}) diff --git a/internal/flags/flags.go b/internal/flags/flags.go index 8d32124..e03cc25 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -5,4 +5,5 @@ var ( VERBOSE bool = false CRON_LEAN bool = false RESTIC_BIN string + DOCKER_IMAGE string ) diff --git a/internal/location.go b/internal/location.go index 5dae649..bf8deb5 100644 --- a/internal/location.go +++ b/internal/location.go @@ -216,7 +216,7 @@ func (l Location) Backup(cron bool, specificBackend string) []error { } cmd := []string{"backup"} - cmd = append(cmd, combineOptions("backup", l, backend)...) + cmd = append(cmd, combineAllOptions("backup", l, backend)...) if cron { cmd = append(cmd, "--tag", buildTag("cron")) } @@ -308,7 +308,10 @@ after: // Forget and optionally prune if isSuccess && l.ForgetOption != "" && l.ForgetOption != LocationForgetNo { - l.Forget(l.ForgetOption == LocationForgetPrune, false) + err := l.Forget(l.ForgetOption == LocationForgetPrune, false) + if err != nil { + errors = append(errors, err) + } } if len(errors) == 0 { @@ -342,7 +345,7 @@ func (l Location) Forget(prune bool, dry bool) error { if dry { cmd = append(cmd, "--dry-run") } - cmd = append(cmd, combineOptions("forget", l, backend)...) + cmd = append(cmd, combineAllOptions("forget", l, backend)...) _, _, err = ExecuteResticCommand(options, cmd...) if err != nil { return err