From a89ba5a40aa50e7f7451202360041b47a32afad1 Mon Sep 17 00:00:00 2001 From: shahvirb Date: Tue, 13 Sep 2022 07:59:46 -0500 Subject: [PATCH 01/10] Update forget.md keep-within argument to be '14d' (#236) keep-within duration can only have units 'y', 'm', 'd', and 'h'. The current documentation of '2w' yields: ```invalid argument "2w" for "--keep-within" flag: invalid unit 'w' found after number 2``` https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy --- docs/markdown/location/forget.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 83eeb847ac7697f3ee2320102188a0c61179623c Mon Sep 17 00:00:00 2001 From: John Burkhardt Date: Tue, 13 Sep 2022 09:04:12 -0400 Subject: [PATCH 02/10] Add command line flag to override docker image. (#233) --- cmd/root.go | 1 + internal/backend.go | 5 +++-- internal/flags/flags.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) 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/internal/backend.go b/internal/backend.go index 40bb9d6..fa3afcc 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 { @@ -160,7 +161,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 +194,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/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 ) From b830667264f66ee5d333ec5f5b4ce3fe494e6d44 Mon Sep 17 00:00:00 2001 From: Chosto Date: Tue, 13 Sep 2022 15:15:02 +0200 Subject: [PATCH 03/10] Use options when calling check or init (#199) --- internal/backend.go | 8 ++++++-- internal/config.go | 12 +++++++++++- internal/location.go | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/internal/backend.go b/internal/backend.go index fa3afcc..0a3c177 100644 --- a/internal/backend.go +++ b/internal/backend.go @@ -122,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 } } diff --git a/internal/config.go b/internal/config.go index 70f3dca..491bda4 100644 --- a/internal/config.go +++ b/internal/config.go @@ -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/location.go b/internal/location.go index 5dae649..d4c73e7 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")) } @@ -342,7 +342,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 From 4d9a2b828e75b7804e4e5ef7ec75580f5b022e91 Mon Sep 17 00:00:00 2001 From: Nicco Date: Tue, 13 Sep 2022 15:16:21 +0200 Subject: [PATCH 04/10] Update config.go --- internal/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config.go b/internal/config.go index 491bda4..7db81b1 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.3" type OptionMap map[string][]interface{} type Options map[string]OptionMap From 874ed52e3be164eccad088f536dcadbc5cec4d32 Mon Sep 17 00:00:00 2001 From: Andreas Wagner Date: Thu, 6 Oct 2022 17:41:01 +0300 Subject: [PATCH 05/10] add more architectures for linux build process (#243) * add more architectures for linux build process equivalent to https://github.com/restic/restic/blob/7d665fa1f4bc8714ffb11da9cf568b4861ab1478/helpers/build-release-binaries/main.go * add solaris and s390x Co-authored-by: Nicco --- build/build.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 { From 3732dcf6ff0bf7ef69762b95245748e1c5dcfa98 Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Mon, 17 Oct 2022 15:02:47 +0200 Subject: [PATCH 06/10] Check for errors on forget after having backuped (#241) --- internal/location.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/location.go b/internal/location.go index d4c73e7..bf8deb5 100644 --- a/internal/location.go +++ b/internal/location.go @@ -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 { From 74979e9a2abaaccd97b93b70d733f002fe6b453f Mon Sep 17 00:00:00 2001 From: Nicco Date: Mon, 17 Oct 2022 15:03:17 +0200 Subject: [PATCH 07/10] Update config.go --- internal/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config.go b/internal/config.go index 7db81b1..a0bbf2f 100644 --- a/internal/config.go +++ b/internal/config.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/viper" ) -const VERSION = "1.7.3" +const VERSION = "1.7.4" type OptionMap map[string][]interface{} type Options map[string]OptionMap From d0c4a32879df3a66472bad36fdef9e0575f43f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Woidig?= <91139971+SimonWoidig@users.noreply.github.com> Date: Tue, 18 Oct 2022 16:17:35 +0200 Subject: [PATCH 08/10] Update install.sh (#246) Add check for bzip2 command existance --- install.sh | 5 +++++ 1 file changed, 5 insertions(+) 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 \ From 58fd41fafbf24fff4a9df75ef600be3e534dc184 Mon Sep 17 00:00:00 2001 From: Nicco Date: Tue, 18 Oct 2022 16:23:27 +0200 Subject: [PATCH 09/10] consistent casing (#247) --- docs/markdown/installation.md | 2 +- docs/markdown/quick.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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. From d0d2fcf0f286646508f2d749188c37300ba44bbc Mon Sep 17 00:00:00 2001 From: Daniel Brennand <52419383+dbrennand@users.noreply.github.com> Date: Sat, 29 Oct 2022 20:32:48 +0100 Subject: [PATCH 10/10] docs: add `dbrennand.autorestic` role (#250) --- docs/markdown/community.md | 1 + 1 file changed, 1 insertion(+) 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