mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-06 18:40:40 +00:00
Compare commits
9 Commits
v1.8.0
...
51a8298f2a
Author | SHA1 | Date | |
---|---|---|---|
|
51a8298f2a | ||
|
f6aa45fd6c | ||
62a81d1420 | |||
e4b33cad1f | |||
|
a82273ec13 | ||
|
2418da5636 | ||
|
7508df7d66 | ||
6e34196220 | |||
|
dc56911a45 |
@@ -42,6 +42,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().BoolVarP(&flags.VERBOSE, "verbose", "v", false, "verbose mode")
|
rootCmd.PersistentFlags().BoolVarP(&flags.VERBOSE, "verbose", "v", false, "verbose mode")
|
||||||
rootCmd.PersistentFlags().StringVar(&flags.RESTIC_BIN, "restic-bin", "restic", "specify custom restic binary")
|
rootCmd.PersistentFlags().StringVar(&flags.RESTIC_BIN, "restic-bin", "restic", "specify custom restic binary")
|
||||||
rootCmd.PersistentFlags().StringVar(&flags.DOCKER_IMAGE, "docker-image", "cupcakearmy/autorestic:"+internal.VERSION, "specify a custom docker image")
|
rootCmd.PersistentFlags().StringVar(&flags.DOCKER_IMAGE, "docker-image", "cupcakearmy/autorestic:"+internal.VERSION, "specify a custom docker image")
|
||||||
|
rootCmd.PersistentFlags().StringVar(&flags.LOCKFILE_PATH, "lockfile-path", "", "specify a custom path for the lockfile (defaults to .autorestic.lock.yml next to the loaded autorestic config file)")
|
||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -61,9 +62,10 @@ func isAutoresticRunning() bool {
|
|||||||
|
|
||||||
lines := strings.Split(out.String(), "\n")
|
lines := strings.Split(out.String(), "\n")
|
||||||
autoresticProcesses := []string{}
|
autoresticProcesses := []string{}
|
||||||
|
currentPid := fmt.Sprint(os.Getpid())
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
if strings.Contains(line, "autorestic") && !strings.Contains(line, "grep autorestic") {
|
if strings.Contains(line, "autorestic") && !strings.Contains(line, "grep autorestic") && !strings.Contains(line, currentPid) {
|
||||||
autoresticProcesses = append(autoresticProcesses, line)
|
autoresticProcesses = append(autoresticProcesses, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,3 +34,11 @@ With `--restic-bin` you can specify to run a specific restic binary. This can be
|
|||||||
```bash
|
```bash
|
||||||
autorestic --restic-bin /some/path/to/my/custom/restic/binary
|
autorestic --restic-bin /some/path/to/my/custom/restic/binary
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `--lockfile-path`
|
||||||
|
|
||||||
|
Specify the path for the lockfile used by `autorestic`. If omitted, this will default to `.autorestic.lock.yml` next to the loaded config file.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
autorestic --lockfile-path /path/to/my/.autorestic.lock.yml
|
||||||
|
```
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
# 🏘 Community
|
# 🏘 Community
|
||||||
|
|
||||||
|
## Software
|
||||||
|
|
||||||
A list of community driven projects. (No official affiliation)
|
A list of community driven projects. (No official affiliation)
|
||||||
|
|
||||||
- SystemD Units: <https://gitlab.com/py_crash/autorestic-systemd-units>
|
- SystemD Units: <https://gitlab.com/py_crash/autorestic-systemd-units>
|
||||||
@@ -9,3 +11,7 @@ A list of community driven projects. (No official affiliation)
|
|||||||
- Ansible Role: <https://github.com/FuzzyMistborn/ansible-role-autorestic>
|
- Ansible Role: <https://github.com/FuzzyMistborn/ansible-role-autorestic>
|
||||||
- Ansible Role: <https://0xacab.org/varac-projects/ansible-role-autorestic>
|
- Ansible Role: <https://0xacab.org/varac-projects/ansible-role-autorestic>
|
||||||
- Ansible Role: <https://github.com/dbrennand/ansible-role-autorestic>
|
- Ansible Role: <https://github.com/dbrennand/ansible-role-autorestic>
|
||||||
|
|
||||||
|
## Writing
|
||||||
|
|
||||||
|
- [restic: excellent resource for local and cloud backup](https://notes.nicfab.eu/en/posts/restic/)
|
||||||
|
10
docs/pnpm-lock.yaml
generated
10
docs/pnpm-lock.yaml
generated
@@ -1332,8 +1332,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
|
resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/katex@0.16.8:
|
/katex@0.16.10:
|
||||||
resolution: {integrity: sha512-ftuDnJbcbOckGY11OO+zg3OofESlbR5DRl2cmN8HeWeeFIV7wTXvAOx8kEjZjobhA+9wh2fbKeO6cdcA9Mnovg==}
|
resolution: {integrity: sha512-ZiqaC04tp2O5utMsl2TEZTXxa6WSC4yo0fv5ML++D3QZv/vx2Mct0mTlRx3O+uUkjfuAgOkzsCmq5MiUEsDDdA==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
commander: 8.3.0
|
commander: 8.3.0
|
||||||
@@ -1811,7 +1811,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/katex': 0.16.3
|
'@types/katex': 0.16.3
|
||||||
devlop: 1.1.0
|
devlop: 1.1.0
|
||||||
katex: 0.16.8
|
katex: 0.16.10
|
||||||
micromark-factory-space: 2.0.0
|
micromark-factory-space: 2.0.0
|
||||||
micromark-util-character: 2.0.1
|
micromark-util-character: 2.0.1
|
||||||
micromark-util-symbol: 2.0.0
|
micromark-util-symbol: 2.0.0
|
||||||
@@ -2354,7 +2354,7 @@ packages:
|
|||||||
github-slugger: 2.0.0
|
github-slugger: 2.0.0
|
||||||
graceful-fs: 4.2.11
|
graceful-fs: 4.2.11
|
||||||
gray-matter: 4.0.3
|
gray-matter: 4.0.3
|
||||||
katex: 0.16.8
|
katex: 0.16.10
|
||||||
lodash.get: 4.4.2
|
lodash.get: 4.4.2
|
||||||
next: 13.5.3(react-dom@18.2.0)(react@18.2.0)
|
next: 13.5.3(react-dom@18.2.0)(react@18.2.0)
|
||||||
next-mdx-remote: 4.4.1(react-dom@18.2.0)(react@18.2.0)
|
next-mdx-remote: 4.4.1(react-dom@18.2.0)(react@18.2.0)
|
||||||
@@ -2510,7 +2510,7 @@ packages:
|
|||||||
'@types/katex': 0.16.3
|
'@types/katex': 0.16.3
|
||||||
hast-util-from-html-isomorphic: 2.0.0
|
hast-util-from-html-isomorphic: 2.0.0
|
||||||
hast-util-to-text: 4.0.0
|
hast-util-to-text: 4.0.0
|
||||||
katex: 0.16.8
|
katex: 0.16.10
|
||||||
unist-util-visit-parents: 6.0.1
|
unist-util-visit-parents: 6.0.1
|
||||||
vfile: 6.0.1
|
vfile: 6.0.1
|
||||||
dev: false
|
dev: false
|
||||||
|
2
go.mod
2
go.mod
@@ -32,5 +32,5 @@ require (
|
|||||||
golang.org/x/text v0.3.8 // indirect
|
golang.org/x/text v0.3.8 // indirect
|
||||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
gopkg.in/yaml.v3 v3.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
4
go.sum
4
go.sum
@@ -487,8 +487,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
@@ -183,6 +183,7 @@ func (b Backend) ExecDocker(l Location, args []string) (int, string, error) {
|
|||||||
case "s3":
|
case "s3":
|
||||||
case "azure":
|
case "azure":
|
||||||
case "gs":
|
case "gs":
|
||||||
|
case "rest":
|
||||||
// No additional setup needed
|
// No additional setup needed
|
||||||
case "rclone":
|
case "rclone":
|
||||||
// Read host rclone config and mount it into the container
|
// Read host rclone config and mount it into the container
|
||||||
|
@@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "1.8.0"
|
const VERSION = "1.8.2"
|
||||||
|
|
||||||
type OptionMap map[string][]interface{}
|
type OptionMap map[string][]interface{}
|
||||||
type Options map[string]OptionMap
|
type Options map[string]OptionMap
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
package flags
|
package flags
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CI bool = false
|
CI bool = false
|
||||||
VERBOSE bool = false
|
VERBOSE bool = false
|
||||||
CRON_LEAN bool = false
|
CRON_LEAN bool = false
|
||||||
RESTIC_BIN string
|
RESTIC_BIN string
|
||||||
DOCKER_IMAGE string
|
DOCKER_IMAGE string
|
||||||
|
LOCKFILE_PATH string
|
||||||
)
|
)
|
||||||
|
@@ -18,18 +18,28 @@ const (
|
|||||||
RUNNING = "running"
|
RUNNING = "running"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getLockfilePath returns the path to the lockfile. If flags.LOCKFILE_PATH is
|
||||||
|
// set, its value is used, otherwise the path is generated relative to the
|
||||||
|
// config file.
|
||||||
|
func getLockfilePath() string {
|
||||||
|
if flags.LOCKFILE_PATH != "" {
|
||||||
|
return flags.LOCKFILE_PATH
|
||||||
|
} else {
|
||||||
|
p := viper.ConfigFileUsed()
|
||||||
|
if p == "" {
|
||||||
|
colors.Error.Println("cannot lock before reading config location")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
return path.Join(path.Dir(p), ".autorestic.lock.yml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getLock() *viper.Viper {
|
func getLock() *viper.Viper {
|
||||||
if lock == nil {
|
if lock == nil {
|
||||||
|
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
lock = viper.New()
|
lock = viper.New()
|
||||||
lock.SetDefault("running", false)
|
lock.SetDefault("running", false)
|
||||||
p := viper.ConfigFileUsed()
|
file = getLockfilePath()
|
||||||
if p == "" {
|
|
||||||
colors.Error.Println("cannot lock before reading config location")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
file = path.Join(path.Dir(p), ".autorestic.lock.yml")
|
|
||||||
if !flags.CRON_LEAN {
|
if !flags.CRON_LEAN {
|
||||||
colors.Faint.Println("Using lock:\t", file)
|
colors.Faint.Println("Using lock:\t", file)
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cupcakearmy/autorestic/internal/flags"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,6 +29,37 @@ func setup(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetLockfilePath(t *testing.T) {
|
||||||
|
t.Run("when flags.LOCKFILE_PATH is set", func(t *testing.T) {
|
||||||
|
flags.LOCKFILE_PATH = "/path/to/my/autorestic.lock.yml"
|
||||||
|
defer func() { flags.LOCKFILE_PATH = "" }()
|
||||||
|
|
||||||
|
p := getLockfilePath()
|
||||||
|
|
||||||
|
if p != "/path/to/my/autorestic.lock.yml" {
|
||||||
|
t.Errorf("got %v, want %v", p, "/path/to/my/autorestic.lock.yml")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("when flags.LOCKFILE_PATH is set", func(t *testing.T) {
|
||||||
|
d, err := os.MkdirTemp("", testDirectory)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error creating temp dir: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
viper.SetConfigFile(d + "/.autorestic.yml")
|
||||||
|
defer viper.Reset()
|
||||||
|
|
||||||
|
flags.LOCKFILE_PATH = ""
|
||||||
|
|
||||||
|
p := getLockfilePath()
|
||||||
|
|
||||||
|
if p != d+"/.autorestic.lock.yml" {
|
||||||
|
t.Errorf("got %v, want %v", p, d+"/.autorestic.lock.yml")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestLock(t *testing.T) {
|
func TestLock(t *testing.T) {
|
||||||
setup(t)
|
setup(t)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user