Compare commits

...

11 Commits

Author SHA1 Message Date
a4b54f9f64 check config bugs 2021-07-11 13:51:04 +02:00
c2e88193cd Update contrib.md 2021-06-06 15:51:50 +02:00
a2ef69d96d Merge pull request #87 from somebox/patch-1
correction to B2 config in the example
2021-06-06 15:48:02 +02:00
Jeremy Seitz
d45949b028 correction to B2 config in the example
This example was missing the `env:` block in YAML, which if missing, caused `autorestic check` to compain:

``` * 'Backends[remote]' has invalid keys: b2_account_id, b2_account_key```
2021-06-06 14:27:26 +02:00
77d47cc697 add arm in install script 2021-05-25 22:57:42 +02:00
a3239c0f3b changelog 2021-05-17 22:40:27 +02:00
90cd3171e5 docs 2021-05-17 22:40:23 +02:00
61673bd88b allow options for backend 2021-05-17 22:34:14 +02:00
41736ea3c4 typos 2021-05-07 11:34:46 +02:00
a7779e04bd Merge pull request #75 from FuzzyMistborn/patch-2
Update update command in docs
2021-05-07 11:31:26 +02:00
Fuzzy
1326e7e53c Update update command in docs 2021-05-06 23:05:34 -04:00
16 changed files with 88 additions and 42 deletions

View File

@@ -5,6 +5,18 @@ 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.1.2] - 2021-07-11
### Fixes
Don't check all backend when running `forget` or `exec` commands.
## [1.1.1] - 2021-05-17
### Added
- Options for backends
## [1.1.0] - 2021-05-06
### Added

View File

@@ -15,7 +15,7 @@ var execCmd = &cobra.Command{
CheckErr(err)
defer lock.Unlock()
CheckErr(internal.CheckConfig())
internal.GetConfig()
selected, err := internal.GetAllOrSelected(cmd, true)
CheckErr(err)

View File

@@ -14,7 +14,7 @@ var forgetCmd = &cobra.Command{
CheckErr(err)
defer lock.Unlock()
CheckErr(internal.CheckConfig())
internal.GetConfig()
selected, err := internal.GetAllOrSelected(cmd, false)
CheckErr(err)

View File

@@ -22,6 +22,7 @@
>
> [Overview](/backend/overview)
> [Available Backends](/backend/available)
> [Options](/backend/options)
> :Collapse label=CLI
>
@@ -36,7 +37,7 @@
> [Exec](/cli/exec)
> [Install](/cli/install)
> [Uninstall](/cli/uninstall)
> [Update](/cli/update)
> [Upgrade](/cli/upgrade)
[Examples](/examples)

View File

@@ -0,0 +1,23 @@
# Options
For the `backup` and `forget` commands you can pass any native flags to `restic`.
> It is also possible to set options for an [a specific location](/location/options).
```yaml
backend:
foo:
type: ...
path: ...
options:
backup:
tag:
- foo
- bar
```
In this example, whenever `autorestic` runs `restic backup` it will append a `--tag abc --tag` to the native command.
For more detail see the [location docs](/location/options) for options, as they are the same
> :ToCPrevNext

View File

@@ -4,7 +4,7 @@
autorestic forget [-l, --location] [-a, --all] [--dry-run] [--prune]
```
This will prune and remove old data form the backends according to the [keep policy you have specified for the location](/location/forget)
This will prune and remove old data form the backends according to the [keep policy you have specified for the location](/location/forget).
The `--dry-run` flag will do a dry run showing what would have been deleted, but won't touch the actual data.

View File

@@ -1,11 +0,0 @@
# Update
Autorestic can update itself! Super handy right? Simply run autorestic update and we will check for you if there are updates for restic and autorestic and install them if necessary.
```bash
autorestic update
```
Updates both restic and autorestic automagically.
> :ToCPrevNext

View File

@@ -0,0 +1,11 @@
# Upgrade
Autorestic can upgrade itself! Super handy right? Simply run autorestic upgrade and we will check for you if there are updates for restic and autorestic and install them if necessary.
```bash
autorestic upgrade
```
Updates both restic and autorestic automagically.
> :ToCPrevNext

View File

@@ -31,8 +31,9 @@ backends:
remote:
type: b2
path: 'myBucket:backup/home'
B2_ACCOUNT_ID: account_id
B2_ACCOUNT_KEY: account_key
env:
B2_ACCOUNT_ID: account_id
B2_ACCOUNT_KEY: account_key
hdd:
type: local

View File

@@ -12,5 +12,6 @@ This amazing people helped the project!
- @ChanceM - Typos
- @TheForcer - Typos
- @themorlan - Typos
- @somebox - Typos
> :ToCPrevNext

View File

@@ -2,6 +2,8 @@
For the `backup` and `forget` commands you can pass any native flags to `restic`.
> It is also possible to set options for an [entire backend](/backend/options).
```yaml
locations:
foo:

View File

@@ -1,4 +1,4 @@
# Update
# Upgrade
## From `0.x` to `1.0`

View File

@@ -23,6 +23,8 @@ elif [[ $NATIVE_ARCH == *"arm64"* || $NATIVE_ARCH == *"aarch64"* ]]; then
ARCH=arm64
elif [[ $NATIVE_ARCH == *"x86"* ]]; then
ARCH=386
elif [[ $NATIVE_ARCH == *"armv7"* ]]; then
ARCH=arm
else
echo "Could not determine Architecure automatically, please check the release page manually: https://github.com/cupcakearmy/autorestic/releases"
exit 1

View File

@@ -17,12 +17,13 @@ type BackendRest struct {
}
type Backend struct {
name string
Type string `yaml:"type,omitempty"`
Path string `yaml:"path,omitempty"`
Key string `yaml:"key,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Rest BackendRest `yaml:"rest,omitempty"`
name string
Type string `yaml:"type,omitempty"`
Path string `yaml:"path,omitempty"`
Key string `yaml:"key,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Rest BackendRest `yaml:"rest,omitempty"`
Options Options `yaml:"options,omitempty"`
}
func GetBackend(name string) (Backend, bool) {

View File

@@ -12,7 +12,7 @@ import (
"github.com/spf13/viper"
)
const VERSION = "1.1.0"
const VERSION = "1.1.2"
var CI bool = false
var VERBOSE bool = false
@@ -140,7 +140,7 @@ func CheckConfig() error {
}
for name, location := range c.Locations {
location.name = name
if err := location.validate(c); err != nil {
if err := location.validate(); err != nil {
return err
}
}
@@ -220,3 +220,13 @@ func (c *Config) SaveConfig() error {
return viper.WriteConfig()
}
func getOptions(options Options, key string) []string {
var selected []string
for k, values := range options[key] {
for _, value := range values {
selected = append(selected, fmt.Sprintf("--%s", k), value)
}
}
return selected
}

View File

@@ -47,7 +47,7 @@ func GetLocation(name string) (Location, bool) {
return l, ok
}
func (l Location) validate(c *Config) error {
func (l Location) validate() error {
if l.From == "" {
return fmt.Errorf(`Location "%s" is missing "from" key`, l.name)
}
@@ -78,17 +78,6 @@ func (l Location) validate(c *Config) error {
return nil
}
func (l Location) getOptions(key string) []string {
var options []string
saved := l.Options[key]
for k, values := range saved {
for _, value := range values {
options = append(options, fmt.Sprintf("--%s", k), value)
}
}
return options
}
func ExecuteHooks(commands []string, options ExecuteOptions) error {
if len(commands) == 0 {
return nil
@@ -164,9 +153,11 @@ func (l Location) Backup(cron bool) []error {
continue
}
flags := l.getOptions("backup")
lFlags := getOptions(l.Options, "backup")
bFlags := getOptions(backend.Options, "backup")
cmd := []string{"backup"}
cmd = append(cmd, flags...)
cmd = append(cmd, lFlags...)
cmd = append(cmd, bFlags...)
if cron {
cmd = append(cmd, "--tag", "cron")
}
@@ -232,7 +223,8 @@ func (l Location) Forget(prune bool, dry bool) error {
options := ExecuteOptions{
Envs: env,
}
flags := l.getOptions("forget")
lFlags := getOptions(l.Options, "forget")
bFlags := getOptions(backend.Options, "forget")
cmd := []string{"forget", "--path", path}
if prune {
cmd = append(cmd, "--prune")
@@ -240,7 +232,8 @@ func (l Location) Forget(prune bool, dry bool) error {
if dry {
cmd = append(cmd, "--dry-run")
}
cmd = append(cmd, flags...)
cmd = append(cmd, lFlags...)
cmd = append(cmd, bFlags...)
out, err := ExecuteResticCommand(options, cmd...)
if VERBOSE {
colors.Faint.Println(out)