mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-06 10:30:39 +00:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
f3c038c716 | |||
59612a97b6 | |||
33319a00ef | |||
8eb14ea14f | |||
70eb9e441f | |||
be25af2d76 | |||
1c436369f0 | |||
6efcce07b7 | |||
|
dc6dd2e712 | ||
|
68628d3776 | ||
40988ef3b4 | |||
fad33fcdaa | |||
|
8cf8a77558 |
20
CHANGELOG.md
20
CHANGELOG.md
@@ -5,6 +5,26 @@ 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.0.7] - 2021-04-26
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for `darwin/arm64` aka Apple Silicon.
|
||||||
|
- Added support for `arm64` and `aarch64` in install scripts.
|
||||||
|
|
||||||
|
## [1.0.6] - 2021-04-24
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for rclone
|
||||||
|
|
||||||
|
## [1.0.5] - 2021-04-24
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Correct exit code on backup failure and better logging/output/feedback.
|
||||||
|
- Check if `from` key is an actual directory.
|
||||||
|
|
||||||
## [1.0.4] - 2021-04-23
|
## [1.0.4] - 2021-04-23
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@@ -16,7 +16,7 @@ import (
|
|||||||
var DIR, _ = filepath.Abs("./dist")
|
var DIR, _ = filepath.Abs("./dist")
|
||||||
|
|
||||||
var targets = map[string][]string{
|
var targets = map[string][]string{
|
||||||
"darwin": {"amd64"},
|
"darwin": {"amd64", "arm64"},
|
||||||
"freebsd": {"386", "amd64", "arm"},
|
"freebsd": {"386", "amd64", "arm"},
|
||||||
"linux": {"386", "amd64", "arm", "arm64"},
|
"linux": {"386", "amd64", "arm", "arm64"},
|
||||||
"netbsd": {"386", "amd64"},
|
"netbsd": {"386", "amd64"},
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/cupcakearmy/autorestic/internal"
|
"github.com/cupcakearmy/autorestic/internal"
|
||||||
|
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -18,9 +21,17 @@ var backupCmd = &cobra.Command{
|
|||||||
|
|
||||||
selected, err := internal.GetAllOrSelected(cmd, false)
|
selected, err := internal.GetAllOrSelected(cmd, false)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
errors := 0
|
||||||
for _, name := range selected {
|
for _, name := range selected {
|
||||||
location, _ := internal.GetLocation(name)
|
location, _ := internal.GetLocation(name)
|
||||||
location.Backup(false)
|
err := location.Backup(false)
|
||||||
|
if err != nil {
|
||||||
|
colors.Error.Println(err)
|
||||||
|
errors++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errors > 0 {
|
||||||
|
CheckErr(fmt.Errorf("%d errors were found", errors))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ var checkCmd = &cobra.Command{
|
|||||||
|
|
||||||
CheckErr(internal.CheckConfig())
|
CheckErr(internal.CheckConfig())
|
||||||
|
|
||||||
colors.Success.Println("Everyting is fine.")
|
colors.Success.Println("Everything is fine.")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,6 @@ autorestic cron
|
|||||||
|
|
||||||
This command is mostly intended to be triggered by an automated system like systemd or crontab.
|
This command is mostly intended to be triggered by an automated system like systemd or crontab.
|
||||||
|
|
||||||
It will run cron jobs es [specified in the cron section](/locations/cron) of a specific location.
|
It will run cron jobs as [specified in the cron section](/location/cron) of a specific location.
|
||||||
|
|
||||||
> :ToCPrevNext
|
> :ToCPrevNext
|
||||||
|
@@ -7,5 +7,6 @@ This amazing people helped the project!
|
|||||||
- @sumnerboy12 - Typos
|
- @sumnerboy12 - Typos
|
||||||
- @FuzzyMistborn - Typos
|
- @FuzzyMistborn - Typos
|
||||||
- @ChanceM - Typos
|
- @ChanceM - Typos
|
||||||
|
- @TheForcer - Typos
|
||||||
|
|
||||||
> :ToCPrevNext
|
> :ToCPrevNext
|
||||||
|
@@ -52,7 +52,7 @@ backends:
|
|||||||
## Check
|
## Check
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
autorestic check -a
|
autorestic check
|
||||||
```
|
```
|
||||||
|
|
||||||
This checks if the config file has any issues. If this is the first time this can take longer as autorestic will setup the backends.
|
This checks if the config file has any issues. If this is the first time this can take longer as autorestic will setup the backends.
|
||||||
|
@@ -16,9 +16,11 @@ else
|
|||||||
fi
|
fi
|
||||||
echo $OS
|
echo $OS
|
||||||
|
|
||||||
NATIVE_ARCH=$(uname -m)
|
NATIVE_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
|
||||||
if [[ $NATIVE_ARCH == *"x86_64"* ]]; then
|
if [[ $NATIVE_ARCH == *"x86_64"* ]]; then
|
||||||
ARCH=amd64
|
ARCH=amd64
|
||||||
|
elif [[ $NATIVE_ARCH == *"arm64"* || $NATIVE_ARCH == *"aarch64"* ]]; then
|
||||||
|
ARCH=arm64
|
||||||
elif [[ $NATIVE_ARCH == *"x86"* ]]; then
|
elif [[ $NATIVE_ARCH == *"x86"* ]]; then
|
||||||
ARCH=386
|
ARCH=386
|
||||||
else
|
else
|
||||||
|
@@ -48,7 +48,7 @@ func (b Backend) generateRepo() (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s:%s", b.Type, parsed.String()), nil
|
return fmt.Sprintf("%s:%s", b.Type, parsed.String()), nil
|
||||||
case "b2", "azure", "gs", "s3", "sftp":
|
case "b2", "azure", "gs", "s3", "sftp", "rclone":
|
||||||
return fmt.Sprintf("%s:%s", b.Type, b.Path), nil
|
return fmt.Sprintf("%s:%s", b.Type, b.Path), nil
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("backend type \"%s\" is invalid", b.Type)
|
return "", fmt.Errorf("backend type \"%s\" is invalid", b.Type)
|
||||||
@@ -121,16 +121,20 @@ func (b Backend) Exec(args []string) error {
|
|||||||
}
|
}
|
||||||
options := ExecuteOptions{Envs: env}
|
options := ExecuteOptions{Envs: env}
|
||||||
out, err := ExecuteResticCommand(options, args...)
|
out, err := ExecuteResticCommand(options, args...)
|
||||||
|
if err != nil {
|
||||||
|
colors.Error.Println(out)
|
||||||
|
return err
|
||||||
|
}
|
||||||
if VERBOSE {
|
if VERBOSE {
|
||||||
colors.Faint.Println(out)
|
colors.Faint.Println(out)
|
||||||
}
|
}
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Backend) ExecDocker(l Location, args []string) error {
|
func (b Backend) ExecDocker(l Location, args []string) (string, error) {
|
||||||
env, err := b.getEnv()
|
env, err := b.getEnv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
volume := l.getVolumeName()
|
volume := l.getVolumeName()
|
||||||
path, _ := l.getPath()
|
path, _ := l.getPath()
|
||||||
@@ -157,8 +161,5 @@ func (b Backend) ExecDocker(l Location, args []string) error {
|
|||||||
}
|
}
|
||||||
docker = append(docker, "restic/restic", "-c", "restic "+strings.Join(args, " "))
|
docker = append(docker, "restic/restic", "-c", "restic "+strings.Join(args, " "))
|
||||||
out, err := ExecuteCommand(options, docker...)
|
out, err := ExecuteCommand(options, docker...)
|
||||||
if VERBOSE {
|
return out, err
|
||||||
colors.Faint.Println(out)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
@@ -120,7 +120,9 @@ func upgradeRestic() error {
|
|||||||
func Upgrade(restic bool) error {
|
func Upgrade(restic bool) error {
|
||||||
// Upgrade restic
|
// Upgrade restic
|
||||||
if restic {
|
if restic {
|
||||||
InstallRestic()
|
if err := InstallRestic(); err != nil {
|
||||||
|
colors.Error.Println(err)
|
||||||
|
}
|
||||||
upgradeRestic()
|
upgradeRestic()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "1.0.4"
|
const VERSION = "1.0.7"
|
||||||
|
|
||||||
var CI bool = false
|
var CI bool = false
|
||||||
var VERBOSE bool = false
|
var VERBOSE bool = false
|
||||||
|
@@ -49,6 +49,18 @@ func (l Location) validate(c *Config) error {
|
|||||||
if l.From == "" {
|
if l.From == "" {
|
||||||
return fmt.Errorf(`Location "%s" is missing "from" key`, l.name)
|
return fmt.Errorf(`Location "%s" is missing "from" key`, l.name)
|
||||||
}
|
}
|
||||||
|
if from, err := GetPathRelativeToConfig(l.From); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
if stat, err := os.Stat(from); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
if !stat.IsDir() {
|
||||||
|
return fmt.Errorf("\"%s\" is not valid directory for location \"%s\"", from, l.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(l.To) == 0 {
|
if len(l.To) == 0 {
|
||||||
return fmt.Errorf(`Location "%s" has no "to" targets`, l.name)
|
return fmt.Errorf(`Location "%s" has no "to" targets`, l.name)
|
||||||
}
|
}
|
||||||
@@ -81,12 +93,13 @@ func ExecuteHooks(commands []string, options ExecuteOptions) error {
|
|||||||
for _, command := range commands {
|
for _, command := range commands {
|
||||||
colors.Body.Println("> " + command)
|
colors.Body.Println("> " + command)
|
||||||
out, err := ExecuteCommand(options, "-c", command)
|
out, err := ExecuteCommand(options, "-c", command)
|
||||||
|
if err != nil {
|
||||||
|
colors.Error.Println(out)
|
||||||
|
return err
|
||||||
|
}
|
||||||
if VERBOSE {
|
if VERBOSE {
|
||||||
colors.Faint.Println(out)
|
colors.Faint.Println(out)
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
colors.Body.Println("")
|
colors.Body.Println("")
|
||||||
return nil
|
return nil
|
||||||
@@ -161,16 +174,16 @@ func (l Location) Backup(cron bool) error {
|
|||||||
switch t {
|
switch t {
|
||||||
case TypeLocal:
|
case TypeLocal:
|
||||||
out, err = ExecuteResticCommand(backupOptions, cmd...)
|
out, err = ExecuteResticCommand(backupOptions, cmd...)
|
||||||
if VERBOSE {
|
|
||||||
colors.Faint.Println(out)
|
|
||||||
}
|
|
||||||
case TypeVolume:
|
case TypeVolume:
|
||||||
err = backend.ExecDocker(l, cmd)
|
out, err = backend.ExecDocker(l, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
colors.Error.Println(out)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if VERBOSE {
|
||||||
|
colors.Faint.Println(out)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// After hooks
|
// After hooks
|
||||||
@@ -271,7 +284,7 @@ func (l Location) Restore(to, from string, force bool) error {
|
|||||||
}
|
}
|
||||||
err = backend.Exec([]string{"restore", "--target", to, "--path", path, "latest"})
|
err = backend.Exec([]string{"restore", "--target", to, "--path", path, "latest"})
|
||||||
case TypeVolume:
|
case TypeVolume:
|
||||||
err = backend.ExecDocker(l, []string{"restore", "--target", ".", "--path", path, "latest"})
|
_, err = backend.ExecDocker(l, []string{"restore", "--target", ".", "--path", path, "latest"})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user