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/docs/markdown/backend/overview.md b/docs/markdown/backend/overview.md index 0c2092a..35714cc 100644 --- a/docs/markdown/backend/overview.md +++ b/docs/markdown/backend/overview.md @@ -2,6 +2,8 @@ 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 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 diff --git a/docs/markdown/contrib.md b/docs/markdown/contrib.md index c478f64..a904d87 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. +- @olofvndrhr - Healthchecks example. - @jin-park-dev - Typos. - @sumnerboy12 - Typos. - @FuzzyMistborn - Typos. diff --git a/docs/markdown/examples.md b/docs/markdown/examples.md index 4de828e..9243bc9 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 @olofvndrhr 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 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 diff --git a/internal/config.go b/internal/config.go index 26c584c..565e413 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) }