Merge pull request #136 from cupcakearmy/1.5.1

1.5.1
This commit is contained in:
Nicco 2021-12-06 17:24:19 +01:00 committed by GitHub
commit 389490c4ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 102 additions and 38 deletions

View File

@ -5,23 +5,34 @@ 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.5.1] - 2021-11-24
### Changed
- use official docker image instead of installing rclone every time docker is used.
### Fixed
- lock file not always next to the config file.
- update / install bugs.
## [1.5.0] - 2021-11-20 ## [1.5.0] - 2021-11-20
### Added ### Added
- Support for multiple paths - Support for multiple paths.
- Improved error handling - Improved error handling.
- Allow for specific snapshot to be restored - Allow for specific snapshot to be restored.
- Docker image - Docker image.
### Fixed ### Fixed
- rclone in docker volumes - rclone in docker volumes.
### Changed ### Changed
- [Breaking Change] Declaration of docker volumes. See: https://autorestic.vercel.app/migration/1.4_1.5 - [Breaking Change] Declaration of docker volumes. See: https://autorestic.vercel.app/migration/1.4_1.5.
- [Breaking Change] Hooks default executing directory now defaults to the config file directory. See: https://autorestic.vercel.app/migration/1.4_1.5 - [Breaking Change] Hooks default executing directory now defaults to the config file directory. See: https://autorestic.vercel.app/migration/1.4_1.5.
## [1.4.1] - 2021-10-31 ## [1.4.1] - 2021-10-31
@ -33,26 +44,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Allow specify to specify a backend for location backup - Allow specify to specify a backend for location backup.
- Global restic flags - Global restic flags.
- Generic ENV support for backends - Generic ENV support for backends.
### Changed ### Changed
- Install now only requires `wget` - Install now only requires `wget`.
- Env variable for the `KEY` has been renamed from `AUTORESTIC_[BACKEND NAME]_KEY` -> `AUTORESTIC_[BACKEND NAME]_RESTIC_PASSWORD` - Env variable for the `KEY` has been renamed from `AUTORESTIC_[BACKEND NAME]_KEY` -> `AUTORESTIC_[BACKEND NAME]_RESTIC_PASSWORD`.
### Fixed ### Fixed
- Error handling during upgrade & uninstall - Error handling during upgrade & uninstall.
## [1.3.0] - 2021-10-26 ## [1.3.0] - 2021-10-26
### Added ### Added
- Pass restic backup metadata as ENV to hooks - Pass restic backup metadata as ENV to hooks.
- Support for `XDG_CONFIG_HOME` and `${HOME}/.config` as default locations for `.autorestic.yaml` file. - Support for `XDG_CONFIG_HOME` and `${HOME}/.config` as default locations for `.autorestic.yaml` file.
- Binary restic flags are now supported - Binary restic flags are now supported.
- Pass encryption keys from env variables or files. - Pass encryption keys from env variables or files.
## [1.2.0] - 2021-08-05 ## [1.2.0] - 2021-08-05
@ -60,12 +71,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Community page - Community page
- Support for yaml references and aliases - Support for yaml references and aliases.
### Fixed ### Fixed
- Better verbose output for hooks - Better verbose output for hooks.
- Better error message for bad formatted configs - Better error message for bad formatted configs.
## [1.1.2] - 2021-07-11 ## [1.1.2] - 2021-07-11
@ -77,24 +88,24 @@ Don't check all backend when running `forget` or `exec` commands.
### Added ### Added
- Options for backends - Options for backends.
## [1.1.0] - 2021-05-06 ## [1.1.0] - 2021-05-06
### Added ### Added
- use custom restic binary - use custom restic binary.
- success & failure hooks - success & failure hooks.
### Fixed ### Fixed
- don't skip other locations on failure - don't skip other locations on failure.
## [1.0.9] - 2021-05-01 ## [1.0.9] - 2021-05-01
### Fixed ### Fixed
- Validation for docker volumes - Validation for docker volumes.
## [1.0.8] - 2021-04-28 ## [1.0.8] - 2021-04-28
@ -117,7 +128,7 @@ Don't check all backend when running `forget` or `exec` commands.
### Added ### Added
- Support for rclone - Support for rclone.
## [1.0.5] - 2021-04-24 ## [1.0.5] - 2021-04-24
@ -130,17 +141,17 @@ Don't check all backend when running `forget` or `exec` commands.
### Added ### Added
- Options to add rest username and password in config - Options to add rest username and password in config.
### Fixed ### Fixed
- Don't add empty strings when saving config - Don't add empty strings when saving config.
## [1.0.3] - 2021-04-20 ## [1.0.3] - 2021-04-20
### Fixed ### Fixed
- Auto upgrade script was not working on linux as linux does not support writing to the binary that is being executed - Auto upgrade script was not working on linux as linux does not support writing to the binary that is being executed.
## [1.0.2] - 2021-04-20 ## [1.0.2] - 2021-04-20
@ -156,7 +167,7 @@ Don't check all backend when running `forget` or `exec` commands.
### Added ### Added
- Completion command for various shells - Completion command for various shells.
## [1.0.0] - 2021-04-17 ## [1.0.0] - 2021-04-17

View File

@ -31,7 +31,7 @@ var backupCmd = &cobra.Command{
location, _ := internal.GetLocation(splitted[0]) location, _ := internal.GetLocation(splitted[0])
errs := location.Backup(false, specificBackend) errs := location.Backup(false, specificBackend)
for _, err := range errs { for _, err := range errs {
colors.Error.Println(err) colors.Error.Printf("%s\n\n", err)
errors++ errors++
} }
} }

View File

@ -11,6 +11,7 @@ var checkCmd = &cobra.Command{
Use: "check", Use: "check",
Short: "Check if everything is setup", Short: "Check if everything is setup",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
internal.GetConfig()
err := lock.Lock() err := lock.Lock()
CheckErr(err) CheckErr(err)
defer lock.Unlock() defer lock.Unlock()

View File

@ -11,6 +11,7 @@ var cronCmd = &cobra.Command{
Short: "Run cron job for automated backups", Short: "Run cron job for automated backups",
Long: `Intended to be mainly triggered by an automated system like systemd or crontab. For each location checks if a cron backup is due and runs it.`, Long: `Intended to be mainly triggered by an automated system like systemd or crontab. For each location checks if a cron backup is due and runs it.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
internal.GetConfig()
internal.CRON_LEAN, _ = cmd.Flags().GetBool("lean") internal.CRON_LEAN, _ = cmd.Flags().GetBool("lean")
err := lock.Lock() err := lock.Lock()
CheckErr(err) CheckErr(err)

View File

@ -13,6 +13,7 @@ var restoreCmd = &cobra.Command{
Short: "Restore backup for location", Short: "Restore backup for location",
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
internal.GetConfig()
err := lock.Lock() err := lock.Lock()
CheckErr(err) CheckErr(err)
defer lock.Unlock() defer lock.Unlock()

View File

@ -46,6 +46,7 @@
> [1.4 → 1.5](/migration/1.4_1.5) > [1.4 → 1.5](/migration/1.4_1.5)
[Examples](/examples) [Examples](/examples)
[Docker](/docker)
[QA](/qa) [QA](/qa)
[Community](/community) [Community](/community)
[Contributors](/contrib) [Contributors](/contrib)

View File

@ -3,6 +3,7 @@
This amazing people helped the project! This amazing people helped the project!
- @agateblue - Docs, Pruning, S3 - @agateblue - Docs, Pruning, S3
- @g-a-c - Update/Install bugs.
- @david-boles - Docs - @david-boles - Docs
- @SebDanielsson - Brew - @SebDanielsson - Brew
- @n194 - AUR Package - @n194 - AUR Package

28
docs/markdown/docker.md Normal file
View File

@ -0,0 +1,28 @@
# 🐳 Docker
The docker image is build with rclone and restic already included. It's ment more as a utility image.
## Remote hosts
For remote backups (S3, B2, GCS, etc.) it's quite easy, as you only need to mount the config file and the data to backup.
```bash
docker run --rm \\
-v $(pwd):/data \\
cupcakearmy/autorestic \\
autorestic backup -va
```
## Rclone
For rclone you will have to also mount the rclone config file to `/root/.config/rclone/rclone.conf`.
To check where it is located you can run the following command: `rclone config file`.
**Example**
```bash
docker run \\
-v /home/user/.config/rclone/rclone.conf:/root/.config/rclone/rclone.conf:ro \\
...
```

View File

@ -14,6 +14,8 @@ wget -qO - https://raw.githubusercontent.com/CupCakeArmy/autorestic/master/insta
There is an official docker image over at [cupcakearmy/autorestic](https://hub.docker.com/r/cupcakearmy/autorestic). There is an official docker image over at [cupcakearmy/autorestic](https://hub.docker.com/r/cupcakearmy/autorestic).
For some examples see [here](/docker).
### Manual ### Manual
You can download the right binary from the release page and simply copy it to `/usr/local/bin` or whatever path you prefer. Autoupdates will still work. You can download the right binary from the release page and simply copy it to `/usr/local/bin` or whatever path you prefer. Autoupdates will still work.

View File

@ -194,15 +194,13 @@ func (b Backend) ExecDocker(l Location, args []string) (string, error) {
splitted := strings.Split(strings.TrimSpace(configFile), "\n") splitted := strings.Split(strings.TrimSpace(configFile), "\n")
configFilePath := splitted[len(splitted)-1] configFilePath := splitted[len(splitted)-1]
docker = append(docker, "--volume", configFilePath+":"+"/root/.config/rclone/rclone.conf:ro") docker = append(docker, "--volume", configFilePath+":"+"/root/.config/rclone/rclone.conf:ro")
// Install rclone in the container
args = append([]string{"apk", "add", "rclone", "&&"}, args...)
default: default:
return "", fmt.Errorf("Backend type \"%s\" is not supported as volume endpoint", b.Type) return "", fmt.Errorf("Backend type \"%s\" is not supported as volume endpoint", b.Type)
} }
for key, value := range env { for key, value := range env {
docker = append(docker, "--env", key+"="+value) docker = append(docker, "--env", key+"="+value)
} }
docker = append(docker, "restic/restic", "-c", strings.Join(args, " ")) docker = append(docker, "cupcakearmy/autorestic:"+VERSION, "-c", strings.Join(args, " "))
out, err := ExecuteCommand(options, docker...) out, err := ExecuteCommand(options, docker...)
return out, err return out, err
} }

View File

@ -87,9 +87,23 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
} }
to := path.Join(INSTALL_PATH, name) to := path.Join(INSTALL_PATH, name)
defer os.Remove(to) // Delete if current, ignore error if file does not exits. defer os.Remove(tmp.Name()) // Cleanup temporary file after thread exits
if err := os.Rename(tmp.Name(), to); err != nil { if err := os.Rename(tmp.Name(), to); err != nil {
return nil colors.Error.Printf("os.Rename() failed (%v), retrying with io.Copy()\n", err.Error())
var src *os.File
var dst *os.File
if src, err = os.Open(tmp.Name()); err != nil {
return err
}
if dst, err = os.Create(to); err != nil {
return err
}
if _, err := io.Copy(dst, src); err != nil {
return err
}
if err := os.Chmod(to, 0755); err != nil {
return err
}
} }
colors.Success.Printf("Successfully installed '%s' under %s\n", name, INSTALL_PATH) colors.Success.Printf("Successfully installed '%s' under %s\n", name, INSTALL_PATH)

View File

@ -16,7 +16,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
const VERSION = "1.5.0" const VERSION = "1.5.1"
var CI bool = false var CI bool = false
var VERBOSE bool = false var VERBOSE bool = false

View File

@ -216,7 +216,8 @@ func (l Location) Backup(cron bool, specificBackend string) []error {
out, err = backend.ExecDocker(l, cmd) out, err = backend.ExecDocker(l, cmd)
} }
if err != nil { if err != nil {
errors = append(errors, err) colors.Error.Println(out)
errors = append(errors, fmt.Errorf("%s@%s:\n%s%s", l.name, backend.name, out, err))
continue continue
} }

View File

@ -19,8 +19,13 @@ func getLock() *viper.Viper {
once.Do(func() { once.Do(func() {
lock = viper.New() lock = viper.New()
lock.SetDefault("running", false) lock.SetDefault("running", false)
p := path.Dir(viper.ConfigFileUsed()) p := viper.ConfigFileUsed()
file = path.Join(p, ".autorestic.lock.yml") if p == "" {
colors.Error.Println("cannot lock before reading config location")
os.Exit(1)
}
file = path.Join(path.Dir(p), ".autorestic.lock.yml")
colors.Faint.Println("Using lock:\t", file)
lock.SetConfigFile(file) lock.SetConfigFile(file)
lock.SetConfigType("yml") lock.SetConfigType("yml")
lock.ReadInConfig() lock.ReadInConfig()