From 8b74a98836a39819bcb763ef81787391383aa973 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Fri, 18 Mar 2022 13:06:19 +0100 Subject: [PATCH 1/7] better error handling --- CHANGELOG.md | 6 ++++++ internal/config.go | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f72ccb1..c689f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.5.8] - 2022-03-18 + +### Fixed + +- Better error handling for bad config files. + ## [1.5.7] - 2022-03-11 ### Added diff --git a/internal/config.go b/internal/config.go index 6d45c4d..d290c7f 100644 --- a/internal/config.go +++ b/internal/config.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/viper" ) -const VERSION = "1.5.7" +const VERSION = "1.5.8" type OptionMap map[string][]interface{} type Options map[string]OptionMap @@ -60,11 +60,16 @@ func GetConfig() *Config { colors.Faint.Println("Using env:\t", envFile) } } else { - cfgFileName := ".autorestic" - colors.Error.Println( - fmt.Sprintf( - "cannot find configuration file '%s.yml' or '%s.yaml'.", - cfgFileName, cfgFileName)) + text := err.Error() + if strings.Contains(text, "no such file or directory") { + cfgFileName := ".autorestic" + colors.Error.Println( + fmt.Sprintf( + "cannot find configuration file '%s.yml' or '%s.yaml'.", + cfgFileName, cfgFileName)) + } else { + colors.Error.Println("could not load config file\n" + text) + } os.Exit(1) } From 79164e3de0c3d52f3b821b2d6493a0f39e855f06 Mon Sep 17 00:00:00 2001 From: ninjabenji <76439609+ninjabenji@users.noreply.github.com> Date: Wed, 6 Apr 2022 21:28:25 +0100 Subject: [PATCH 2/7] Add lower case warning for backend name If uppercase characters are used in a backend name a check (and I assume other actions) will fail. --- docs/markdown/backend/overview.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/markdown/backend/overview.md b/docs/markdown/backend/overview.md index 0c2092a..ca7de86 100644 --- a/docs/markdown/backend/overview.md +++ b/docs/markdown/backend/overview.md @@ -1,6 +1,7 @@ # 💽 Backends Backends are the outputs of the backup process. Each location needs at least one. +Note: names of backends MUST be lower case! ```yaml | .autorestic.yml version: 2 From a3e539b0b7d69df7d4b3f4dbc299b46baaafd292 Mon Sep 17 00:00:00 2001 From: ninjabenji <76439609+ninjabenji@users.noreply.github.com> Date: Thu, 7 Apr 2022 10:00:28 +0100 Subject: [PATCH 3/7] Add line break in documentation --- docs/markdown/backend/overview.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/markdown/backend/overview.md b/docs/markdown/backend/overview.md index ca7de86..35714cc 100644 --- a/docs/markdown/backend/overview.md +++ b/docs/markdown/backend/overview.md @@ -1,6 +1,7 @@ # 💽 Backends Backends are the outputs of the backup process. Each location needs at least one. + Note: names of backends MUST be lower case! ```yaml | .autorestic.yml From b4cc0f0ab1dc5d106f4cce80275286f8e1f3307e Mon Sep 17 00:00:00 2001 From: ninjabenji <76439609+ninjabenji@users.noreply.github.com> Date: Thu, 7 Apr 2022 10:32:17 +0100 Subject: [PATCH 4/7] Add warning about location names. Location names need to be lower case in order to work properly. --- docs/markdown/location/overview.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/markdown/location/overview.md b/docs/markdown/location/overview.md index 1b3dd96..ccde261 100644 --- a/docs/markdown/location/overview.md +++ b/docs/markdown/location/overview.md @@ -3,6 +3,7 @@ Locations can be seen as the input to the backup process. Generally this is simply a folder. The paths can be relative from the config file. A location can have multiple backends, so that the data is secured across multiple servers. +Note: names of locations MUST be lower case! ```yaml | .autorestic.yml version: 2 From 1e62f6cb050c6cdcb46b6f80cbe74821c4e68e88 Mon Sep 17 00:00:00 2001 From: ninjabenji <76439609+ninjabenji@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:31:42 +0100 Subject: [PATCH 5/7] DOC - Note on config filename extension Seems the config file can be located wherever needed but not using an extension or using an extension other than .yml causes the following error could not load config file Unsupported Config Type "" --- docs/markdown/cli/general.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/markdown/cli/general.md b/docs/markdown/cli/general.md index 748c7bc..2dca58d 100644 --- a/docs/markdown/cli/general.md +++ b/docs/markdown/cli/general.md @@ -2,7 +2,7 @@ ## `-c, --config` -Specify the config file to be used. +Specify the config file to be used (must use .yml as an extension). If omitted `autorestic` will search for for a `.autorestic.yml` in the current directory and your home directory. ```bash From 0f6c34dc6bae36edaecce71d53288436fab71d50 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Tue, 12 Apr 2022 23:59:12 +0200 Subject: [PATCH 6/7] healthcheck example --- docs/markdown/contrib.md | 1 + docs/markdown/examples.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/markdown/contrib.md b/docs/markdown/contrib.md index c478f64..810399f 100644 --- a/docs/markdown/contrib.md +++ b/docs/markdown/contrib.md @@ -9,6 +9,7 @@ This amazing people helped the project! - @david-boles - Docs. - @SebDanielsson - Brew. - @n194 - AUR Package. +- @Zottelchen - Healthchecks example. - @jin-park-dev - Typos. - @sumnerboy12 - Typos. - @FuzzyMistborn - Typos. diff --git a/docs/markdown/examples.md b/docs/markdown/examples.md index 4de828e..2f8ca17 100644 --- a/docs/markdown/examples.md +++ b/docs/markdown/examples.md @@ -14,4 +14,27 @@ This can come in handy if a backup process crashed or if it was accidentally can autorestic exec -b my-backend -- unlock ``` +## Use hooks to integrate with [healthchecks](https://healthchecks.io/) + +> Thanks to @Zottelchen for providing it ❤️ + +```yaml +extras: + healthchecks: &healthchecks + hooks: + before: + - 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Starting backup for location: ${AUTORESTIC_LOCATION}" https:///ping//start' + failure: + - 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Backup failed for location: ${AUTORESTIC_LOCATION}" https:///ping//fail' + success: + - 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Backup successful for location: ${AUTORESTIC_LOCATION}" https:///ping/' + +locations: + something: + <<: *healthchecks + from: /somewhere + to: + - somewhere-else +``` + > :ToCPrevNext From 2da440a1cd1c8ed0ae39619cc7bd08f3b938a256 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Wed, 13 Apr 2022 08:55:53 +0200 Subject: [PATCH 7/7] richtiattribution --- docs/markdown/contrib.md | 2 +- docs/markdown/examples.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/markdown/contrib.md b/docs/markdown/contrib.md index 810399f..a904d87 100644 --- a/docs/markdown/contrib.md +++ b/docs/markdown/contrib.md @@ -9,7 +9,7 @@ This amazing people helped the project! - @david-boles - Docs. - @SebDanielsson - Brew. - @n194 - AUR Package. -- @Zottelchen - Healthchecks example. +- @olofvndrhr - Healthchecks example. - @jin-park-dev - Typos. - @sumnerboy12 - Typos. - @FuzzyMistborn - Typos. diff --git a/docs/markdown/examples.md b/docs/markdown/examples.md index 2f8ca17..9243bc9 100644 --- a/docs/markdown/examples.md +++ b/docs/markdown/examples.md @@ -16,7 +16,7 @@ autorestic exec -b my-backend -- unlock ## Use hooks to integrate with [healthchecks](https://healthchecks.io/) -> Thanks to @Zottelchen for providing it ❤️ +> Thanks to @olofvndrhr for providing it ❤️ ```yaml extras: