mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-07 11:00:39 +00:00
Compare commits
17 Commits
v1.7.11
...
752edefc2c
Author | SHA1 | Date | |
---|---|---|---|
|
752edefc2c | ||
62a81d1420 | |||
|
de918cf6d7 | ||
e4b33cad1f | |||
|
a82273ec13 | ||
|
2418da5636 | ||
|
7508df7d66 | ||
6e34196220 | |||
|
dc56911a45 | ||
edb3ba35d8 | |||
|
12f6143bb4 | ||
|
a6bf1d1408 | ||
|
13aa560fda | ||
|
bbb1c85cad | ||
|
4cc44315ab | ||
|
b3440cd87c | ||
|
4848702929 |
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.21-alpine as builder
|
||||
FROM golang:1.22-alpine as builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY go.* .
|
||||
@@ -7,7 +7,7 @@ COPY . .
|
||||
RUN go build
|
||||
|
||||
FROM restic/restic:0.16.4
|
||||
RUN apk add --no-cache rclone bash curl
|
||||
RUN apk add --no-cache rclone bash curl docker-cli
|
||||
COPY --from=builder /app/autorestic /usr/bin/autorestic
|
||||
ENTRYPOINT []
|
||||
CMD [ "autorestic" ]
|
||||
|
@@ -34,7 +34,7 @@ Autorestic is a wrapper around the amazing [restic](https://restic.net/). While
|
||||
- Backup locations to multiple backends
|
||||
- Snapshot policies and pruning
|
||||
- Fully encrypted
|
||||
- Pre/After hooks
|
||||
- Before/after backup hooks
|
||||
- Exclude pattern/files
|
||||
- Cron jobs for automatic backup
|
||||
- Backup & Restore docker volume
|
||||
|
81
cmd/unlock.go
Normal file
81
cmd/unlock.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var unlockCmd = &cobra.Command{
|
||||
Use: "unlock",
|
||||
Short: "Unlock autorestic only if you are sure that no other instance is running",
|
||||
Long: `Unlock autorestic only if you are sure that no other instance is running.
|
||||
To check you can run "ps aux | grep autorestic".`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
|
||||
force, _ := cmd.Flags().GetBool("force")
|
||||
|
||||
if !force && isAutoresticRunning() {
|
||||
colors.Error.Print("Another autorestic instance is running. Are you sure you want to unlock? (yes/no): ")
|
||||
var response string
|
||||
fmt.Scanln(&response)
|
||||
if strings.ToLower(response) != "yes" {
|
||||
colors.Primary.Println("Unlocking aborted.")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err := lock.Unlock()
|
||||
if err != nil {
|
||||
colors.Error.Println("Could not unlock:", err)
|
||||
return
|
||||
}
|
||||
|
||||
colors.Success.Println("Unlock successful")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(unlockCmd)
|
||||
unlockCmd.Flags().Bool("force", false, "force unlock")
|
||||
}
|
||||
|
||||
// isAutoresticRunning checks if autorestic is running
|
||||
// and returns true if it is.
|
||||
// It also prints the processes to stdout.
|
||||
func isAutoresticRunning() bool {
|
||||
cmd := exec.Command("sh", "-c", "ps aux | grep autorestic")
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
lines := strings.Split(out.String(), "\n")
|
||||
autoresticProcesses := []string{}
|
||||
currentPid := fmt.Sprint(os.Getpid())
|
||||
|
||||
for _, line := range lines {
|
||||
if strings.Contains(line, "autorestic") && !strings.Contains(line, "grep autorestic") && !strings.Contains(line, currentPid) {
|
||||
autoresticProcesses = append(autoresticProcesses, line)
|
||||
}
|
||||
}
|
||||
|
||||
if len(autoresticProcesses) > 0 {
|
||||
colors.Faint.Println("Found autorestic processes:")
|
||||
for _, proc := range autoresticProcesses {
|
||||
colors.Faint.Println(proc)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
"dev": "NEXT_TELEMETRY_DISABLED=1 next"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^13.5.3",
|
||||
"next": "^14.1.1",
|
||||
"nextra": "^2.13.1",
|
||||
"nextra-theme-docs": "^2.13.1",
|
||||
"react": "^18.2.0",
|
||||
|
32
docs/pages/cli/unlock.md
Normal file
32
docs/pages/cli/unlock.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Unlock
|
||||
|
||||
In case autorestic throws the error message `an instance is already running. exiting`, but there is no instance running you can unlock the lock.
|
||||
|
||||
To verify that there is no instance running you can use `ps aux | grep autorestic`.
|
||||
|
||||
Example with no instance running:
|
||||
|
||||
```bash
|
||||
> ps aux | grep autorestic
|
||||
root 39260 0.0 0.0 6976 2696 pts/11 S+ 19:41 0:00 grep autorestic
|
||||
```
|
||||
|
||||
Example with an instance running:
|
||||
|
||||
```bash
|
||||
> ps aux | grep autorestic
|
||||
root 29465 0.0 0.0 1162068 7380 pts/7 Sl+ 19:28 0:00 autorestic --ci backup -a
|
||||
root 39260 0.0 0.0 6976 2696 pts/11 S+ 19:41 0:00 grep autorestic
|
||||
```
|
||||
|
||||
**If an instance is running you should not unlock as it could lead to data loss!**
|
||||
|
||||
```bash
|
||||
autorestic unlock
|
||||
```
|
||||
|
||||
Use the `--force` to prevent the confirmation prompt if an instance is running.
|
||||
|
||||
```bash
|
||||
autorestic unlock --force
|
||||
```
|
@@ -1,5 +1,7 @@
|
||||
# 🏘 Community
|
||||
|
||||
## Software
|
||||
|
||||
A list of community driven projects. (No official affiliation)
|
||||
|
||||
- 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://0xacab.org/varac-projects/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/)
|
||||
|
@@ -56,6 +56,8 @@ version: 2
|
||||
|
||||
extras:
|
||||
hooks: &foo
|
||||
prevalidate:
|
||||
- echo "Wake up!"
|
||||
before:
|
||||
- echo "Hello"
|
||||
after:
|
||||
|
@@ -13,7 +13,7 @@ Autorestic is a wrapper around the amazing [restic](https://restic.net/). While
|
||||
- Backup locations to multiple backends
|
||||
- Snapshot policies and pruning
|
||||
- Fully encrypted
|
||||
- Pre/After hooks
|
||||
- Before/after backup hooks
|
||||
- Exclude pattern/files
|
||||
- Cron jobs for automatic backup
|
||||
- Backup & Restore docker volumes
|
||||
|
@@ -6,23 +6,28 @@ They consist of a list of commands that will be executed in the same directory a
|
||||
|
||||
The following hooks groups are supported, none are required:
|
||||
|
||||
- `prevalidate`
|
||||
- `before`
|
||||
- `after`
|
||||
- `failure`
|
||||
- `success`
|
||||
|
||||
The difference between `prevalidate` and `before` hooks are that `prevalidate` is run before checking the backup location is valid, including checking that the `from` directories exist. This can be useful, for example, to mount the source filesystem that contains the directories listed in `from`.
|
||||
|
||||
```yml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to: my-backend
|
||||
hooks:
|
||||
prevalidate:
|
||||
- echo "Checks"
|
||||
before:
|
||||
- echo "One"
|
||||
- echo "Two"
|
||||
- echo "Three"
|
||||
after:
|
||||
- echo "Byte"
|
||||
- echo "Bye"
|
||||
failure:
|
||||
- echo "Something went wrong"
|
||||
success:
|
||||
@@ -31,13 +36,15 @@ locations:
|
||||
|
||||
## Flowchart
|
||||
|
||||
1. `before` hook
|
||||
2. Run backup
|
||||
3. `after` hook
|
||||
4. - `success` hook if no errors were found
|
||||
1. `prevalidate` hook
|
||||
2. Check backup location
|
||||
3. `before` hook
|
||||
4. Run backup
|
||||
5. `after` hook
|
||||
6. - `success` hook if no errors were found
|
||||
- `failure` hook if at least one error was encountered
|
||||
|
||||
If the `before` hook encounters errors the backup and `after` hooks will be skipped and only the `failed` hooks will run.
|
||||
If either the `prevalidate` or `before` hook encounters errors then the backup and `after` hooks will be skipped and only the `failed` hooks will run.
|
||||
|
||||
## Environment variables
|
||||
|
||||
|
137
docs/pnpm-lock.yaml
generated
137
docs/pnpm-lock.yaml
generated
@@ -6,14 +6,14 @@ settings:
|
||||
|
||||
dependencies:
|
||||
next:
|
||||
specifier: ^13.5.3
|
||||
version: 13.5.3(react-dom@18.2.0)(react@18.2.0)
|
||||
specifier: ^14.1.1
|
||||
version: 14.1.1(react-dom@18.2.0)(react@18.2.0)
|
||||
nextra:
|
||||
specifier: ^2.13.1
|
||||
version: 2.13.1(next@13.5.3)(react-dom@18.2.0)(react@18.2.0)
|
||||
version: 2.13.1(next@14.1.1)(react-dom@18.2.0)(react@18.2.0)
|
||||
nextra-theme-docs:
|
||||
specifier: ^2.13.1
|
||||
version: 2.13.1(next@13.5.3)(nextra@2.13.1)(react-dom@18.2.0)(react@18.2.0)
|
||||
version: 2.13.1(next@14.1.1)(nextra@2.13.1)(react-dom@18.2.0)(react@18.2.0)
|
||||
react:
|
||||
specifier: ^18.2.0
|
||||
version: 18.2.0
|
||||
@@ -196,12 +196,12 @@ packages:
|
||||
'@napi-rs/simple-git-win32-x64-msvc': 0.1.9
|
||||
dev: false
|
||||
|
||||
/@next/env@13.5.3:
|
||||
resolution: {integrity: sha512-X4te86vsbjsB7iO4usY9jLPtZ827Mbx+WcwNBGUOIuswuTAKQtzsuoxc/6KLxCMvogKG795MhrR1LDhYgDvasg==}
|
||||
/@next/env@14.1.1:
|
||||
resolution: {integrity: sha512-7CnQyD5G8shHxQIIg3c7/pSeYFeMhsNbpU/bmvH7ZnDql7mNRgg8O2JZrhrc/soFnfBnKP4/xXNiiSIPn2w8gA==}
|
||||
dev: false
|
||||
|
||||
/@next/swc-darwin-arm64@13.5.3:
|
||||
resolution: {integrity: sha512-6hiYNJxJmyYvvKGrVThzo4nTcqvqUTA/JvKim7Auaj33NexDqSNwN5YrrQu+QhZJCIpv2tULSHt+lf+rUflLSw==}
|
||||
/@next/swc-darwin-arm64@14.1.1:
|
||||
resolution: {integrity: sha512-yDjSFKQKTIjyT7cFv+DqQfW5jsD+tVxXTckSe1KIouKk75t1qZmj/mV3wzdmFb0XHVGtyRjDMulfVG8uCKemOQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
@@ -209,8 +209,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-darwin-x64@13.5.3:
|
||||
resolution: {integrity: sha512-UpBKxu2ob9scbpJyEq/xPgpdrgBgN3aLYlxyGqlYX5/KnwpJpFuIHU2lx8upQQ7L+MEmz+fA1XSgesoK92ppwQ==}
|
||||
/@next/swc-darwin-x64@14.1.1:
|
||||
resolution: {integrity: sha512-KCQmBL0CmFmN8D64FHIZVD9I4ugQsDBBEJKiblXGgwn7wBCSe8N4Dx47sdzl4JAg39IkSN5NNrr8AniXLMb3aw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
@@ -218,8 +218,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-linux-arm64-gnu@13.5.3:
|
||||
resolution: {integrity: sha512-5AzM7Yx1Ky+oLY6pHs7tjONTF22JirDPd5Jw/3/NazJ73uGB05NqhGhB4SbeCchg7SlVYVBeRMrMSZwJwq/xoA==}
|
||||
/@next/swc-linux-arm64-gnu@14.1.1:
|
||||
resolution: {integrity: sha512-YDQfbWyW0JMKhJf/T4eyFr4b3tceTorQ5w2n7I0mNVTFOvu6CGEzfwT3RSAQGTi/FFMTFcuspPec/7dFHuP7Eg==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
@@ -227,8 +227,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-linux-arm64-musl@13.5.3:
|
||||
resolution: {integrity: sha512-A/C1shbyUhj7wRtokmn73eBksjTM7fFQoY2v/0rTM5wehpkjQRLOXI8WJsag2uLhnZ4ii5OzR1rFPwoD9cvOgA==}
|
||||
/@next/swc-linux-arm64-musl@14.1.1:
|
||||
resolution: {integrity: sha512-fiuN/OG6sNGRN/bRFxRvV5LyzLB8gaL8cbDH5o3mEiVwfcMzyE5T//ilMmaTrnA8HLMS6hoz4cHOu6Qcp9vxgQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
@@ -236,8 +236,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-linux-x64-gnu@13.5.3:
|
||||
resolution: {integrity: sha512-FubPuw/Boz8tKkk+5eOuDHOpk36F80rbgxlx4+xty/U71e3wZZxVYHfZXmf0IRToBn1Crb8WvLM9OYj/Ur815g==}
|
||||
/@next/swc-linux-x64-gnu@14.1.1:
|
||||
resolution: {integrity: sha512-rv6AAdEXoezjbdfp3ouMuVqeLjE1Bin0AuE6qxE6V9g3Giz5/R3xpocHoAi7CufRR+lnkuUjRBn05SYJ83oKNQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
@@ -245,8 +245,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-linux-x64-musl@13.5.3:
|
||||
resolution: {integrity: sha512-DPw8nFuM1uEpbX47tM3wiXIR0Qa+atSzs9Q3peY1urkhofx44o7E1svnq+a5Q0r8lAcssLrwiM+OyJJgV/oj7g==}
|
||||
/@next/swc-linux-x64-musl@14.1.1:
|
||||
resolution: {integrity: sha512-YAZLGsaNeChSrpz/G7MxO3TIBLaMN8QWMr3X8bt6rCvKovwU7GqQlDu99WdvF33kI8ZahvcdbFsy4jAFzFX7og==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
@@ -254,8 +254,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-win32-arm64-msvc@13.5.3:
|
||||
resolution: {integrity: sha512-zBPSP8cHL51Gub/YV8UUePW7AVGukp2D8JU93IHbVDu2qmhFAn9LWXiOOLKplZQKxnIPUkJTQAJDCWBWU4UWUA==}
|
||||
/@next/swc-win32-arm64-msvc@14.1.1:
|
||||
resolution: {integrity: sha512-1L4mUYPBMvVDMZg1inUYyPvFSduot0g73hgfD9CODgbr4xiTYe0VOMTZzaRqYJYBA9mana0x4eaAaypmWo1r5A==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
@@ -263,8 +263,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-win32-ia32-msvc@13.5.3:
|
||||
resolution: {integrity: sha512-ONcL/lYyGUj4W37D4I2I450SZtSenmFAvapkJQNIJhrPMhzDU/AdfLkW98NvH1D2+7FXwe7yclf3+B7v28uzBQ==}
|
||||
/@next/swc-win32-ia32-msvc@14.1.1:
|
||||
resolution: {integrity: sha512-jvIE9tsuj9vpbbXlR5YxrghRfMuG0Qm/nZ/1KDHc+y6FpnZ/apsgh+G6t15vefU0zp3WSpTMIdXRUsNl/7RSuw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
@@ -272,8 +272,8 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@next/swc-win32-x64-msvc@13.5.3:
|
||||
resolution: {integrity: sha512-2Vz2tYWaLqJvLcWbbTlJ5k9AN6JD7a5CN2pAeIzpbecK8ZF/yobA39cXtv6e+Z8c5UJuVOmaTldEAIxvsIux/Q==}
|
||||
/@next/swc-win32-x64-msvc@14.1.1:
|
||||
resolution: {integrity: sha512-S6K6EHDU5+1KrBDLko7/c1MNy/Ya73pIAmvKeFwsF4RmBFJSO7/7YeD4FnZ4iBdzE69PpQ4sOMU9ORKeNuxe8A==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
@@ -473,8 +473,8 @@ packages:
|
||||
streamsearch: 1.1.0
|
||||
dev: false
|
||||
|
||||
/caniuse-lite@1.0.30001542:
|
||||
resolution: {integrity: sha512-UrtAXVcj1mvPBFQ4sKd38daP8dEcXXr5sQe6QNNinaPd0iA/cxg9/l3VrSdL73jgw5sKyuQ6jNgiKO12W3SsVA==}
|
||||
/caniuse-lite@1.0.30001617:
|
||||
resolution: {integrity: sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==}
|
||||
dev: false
|
||||
|
||||
/ccount@2.0.1:
|
||||
@@ -1052,10 +1052,6 @@ packages:
|
||||
resolution: {integrity: sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==}
|
||||
dev: false
|
||||
|
||||
/glob-to-regexp@0.4.1:
|
||||
resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==}
|
||||
dev: false
|
||||
|
||||
/graceful-fs@4.2.11:
|
||||
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
|
||||
dev: false
|
||||
@@ -1332,8 +1328,8 @@ packages:
|
||||
resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
|
||||
dev: false
|
||||
|
||||
/katex@0.16.8:
|
||||
resolution: {integrity: sha512-ftuDnJbcbOckGY11OO+zg3OofESlbR5DRl2cmN8HeWeeFIV7wTXvAOx8kEjZjobhA+9wh2fbKeO6cdcA9Mnovg==}
|
||||
/katex@0.16.10:
|
||||
resolution: {integrity: sha512-ZiqaC04tp2O5utMsl2TEZTXxa6WSC4yo0fv5ML++D3QZv/vx2Mct0mTlRx3O+uUkjfuAgOkzsCmq5MiUEsDDdA==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
commander: 8.3.0
|
||||
@@ -1811,7 +1807,7 @@ packages:
|
||||
dependencies:
|
||||
'@types/katex': 0.16.3
|
||||
devlop: 1.1.0
|
||||
katex: 0.16.8
|
||||
katex: 0.16.10
|
||||
micromark-factory-space: 2.0.0
|
||||
micromark-util-character: 2.0.1
|
||||
micromark-util-symbol: 2.0.0
|
||||
@@ -2245,33 +2241,33 @@ packages:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/next-seo@6.1.0(next@13.5.3)(react-dom@18.2.0)(react@18.2.0):
|
||||
/next-seo@6.1.0(next@14.1.1)(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-iMBpFoJsR5zWhguHJvsoBDxDSmdYTHtnVPB1ij+CD0NReQCP78ZxxbdL9qkKIf4oEuZEqZkrjAQLB0bkII7RYA==}
|
||||
peerDependencies:
|
||||
next: ^8.1.1-canary.54 || >=9.0.0
|
||||
react: '>=16.0.0'
|
||||
react-dom: '>=16.0.0'
|
||||
dependencies:
|
||||
next: 13.5.3(react-dom@18.2.0)(react@18.2.0)
|
||||
next: 14.1.1(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/next-themes@0.2.1(next@13.5.3)(react-dom@18.2.0)(react@18.2.0):
|
||||
/next-themes@0.2.1(next@14.1.1)(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-B+AKNfYNIzh0vqQQKqQItTS8evEouKD7H5Hj3kmuPERwddR2TxvDSFZuTj6T7Jfn1oyeUyJMydPl1Bkxkh0W7A==}
|
||||
peerDependencies:
|
||||
next: '*'
|
||||
react: '*'
|
||||
react-dom: '*'
|
||||
dependencies:
|
||||
next: 13.5.3(react-dom@18.2.0)(react@18.2.0)
|
||||
next: 14.1.1(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/next@13.5.3(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-4Nt4HRLYDW/yRpJ/QR2t1v63UOMS55A38dnWv3UDOWGezuY0ZyFO1ABNbD7mulVzs9qVhgy2+ppjdsANpKP1mg==}
|
||||
engines: {node: '>=16.14.0'}
|
||||
/next@14.1.1(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-McrGJqlGSHeaz2yTRPkEucxQKe5Zq7uPwyeHNmJaZNY4wx9E9QdxmTp310agFRoMuIYgQrCrT3petg13fSVOww==}
|
||||
engines: {node: '>=18.17.0'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@opentelemetry/api': ^1.1.0
|
||||
@@ -2284,32 +2280,31 @@ packages:
|
||||
sass:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@next/env': 13.5.3
|
||||
'@next/env': 14.1.1
|
||||
'@swc/helpers': 0.5.2
|
||||
busboy: 1.6.0
|
||||
caniuse-lite: 1.0.30001542
|
||||
postcss: 8.4.14
|
||||
caniuse-lite: 1.0.30001617
|
||||
graceful-fs: 4.2.11
|
||||
postcss: 8.4.31
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
styled-jsx: 5.1.1(react@18.2.0)
|
||||
watchpack: 2.4.0
|
||||
zod: 3.21.4
|
||||
optionalDependencies:
|
||||
'@next/swc-darwin-arm64': 13.5.3
|
||||
'@next/swc-darwin-x64': 13.5.3
|
||||
'@next/swc-linux-arm64-gnu': 13.5.3
|
||||
'@next/swc-linux-arm64-musl': 13.5.3
|
||||
'@next/swc-linux-x64-gnu': 13.5.3
|
||||
'@next/swc-linux-x64-musl': 13.5.3
|
||||
'@next/swc-win32-arm64-msvc': 13.5.3
|
||||
'@next/swc-win32-ia32-msvc': 13.5.3
|
||||
'@next/swc-win32-x64-msvc': 13.5.3
|
||||
'@next/swc-darwin-arm64': 14.1.1
|
||||
'@next/swc-darwin-x64': 14.1.1
|
||||
'@next/swc-linux-arm64-gnu': 14.1.1
|
||||
'@next/swc-linux-arm64-musl': 14.1.1
|
||||
'@next/swc-linux-x64-gnu': 14.1.1
|
||||
'@next/swc-linux-x64-musl': 14.1.1
|
||||
'@next/swc-win32-arm64-msvc': 14.1.1
|
||||
'@next/swc-win32-ia32-msvc': 14.1.1
|
||||
'@next/swc-win32-x64-msvc': 14.1.1
|
||||
transitivePeerDependencies:
|
||||
- '@babel/core'
|
||||
- babel-plugin-macros
|
||||
dev: false
|
||||
|
||||
/nextra-theme-docs@2.13.1(next@13.5.3)(nextra@2.13.1)(react-dom@18.2.0)(react@18.2.0):
|
||||
/nextra-theme-docs@2.13.1(next@14.1.1)(nextra@2.13.1)(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-mckNuKa0AmBbRdPCJ/OQ55KZx5MGH8moomMHYB3XVGXQqmXimOq1/2WZQiBdFx9u43KtfEvqZbQE8oGDIrfIsQ==}
|
||||
peerDependencies:
|
||||
next: '>=9.5.3'
|
||||
@@ -2326,17 +2321,17 @@ packages:
|
||||
git-url-parse: 13.1.0
|
||||
intersection-observer: 0.12.2
|
||||
match-sorter: 6.3.1
|
||||
next: 13.5.3(react-dom@18.2.0)(react@18.2.0)
|
||||
next-seo: 6.1.0(next@13.5.3)(react-dom@18.2.0)(react@18.2.0)
|
||||
next-themes: 0.2.1(next@13.5.3)(react-dom@18.2.0)(react@18.2.0)
|
||||
nextra: 2.13.1(next@13.5.3)(react-dom@18.2.0)(react@18.2.0)
|
||||
next: 14.1.1(react-dom@18.2.0)(react@18.2.0)
|
||||
next-seo: 6.1.0(next@14.1.1)(react-dom@18.2.0)(react@18.2.0)
|
||||
next-themes: 0.2.1(next@14.1.1)(react-dom@18.2.0)(react@18.2.0)
|
||||
nextra: 2.13.1(next@14.1.1)(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
scroll-into-view-if-needed: 3.1.0
|
||||
zod: 3.22.2
|
||||
dev: false
|
||||
|
||||
/nextra@2.13.1(next@13.5.3)(react-dom@18.2.0)(react@18.2.0):
|
||||
/nextra@2.13.1(next@14.1.1)(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-FbHwI5EFkbvEWJZ2/ghyPmqd1AmW8f7qVZbF1ApcuvyW1r/Y9FdLLUJZtlUp8DvREgmSF53K2jX9tVPEfmLNIQ==}
|
||||
engines: {node: '>=16'}
|
||||
peerDependencies:
|
||||
@@ -2354,9 +2349,9 @@ packages:
|
||||
github-slugger: 2.0.0
|
||||
graceful-fs: 4.2.11
|
||||
gray-matter: 4.0.3
|
||||
katex: 0.16.8
|
||||
katex: 0.16.10
|
||||
lodash.get: 4.4.2
|
||||
next: 13.5.3(react-dom@18.2.0)(react@18.2.0)
|
||||
next: 14.1.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)
|
||||
p-limit: 3.1.0
|
||||
react: 18.2.0
|
||||
@@ -2457,8 +2452,8 @@ packages:
|
||||
resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}
|
||||
dev: false
|
||||
|
||||
/postcss@8.4.14:
|
||||
resolution: {integrity: sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==}
|
||||
/postcss@8.4.31:
|
||||
resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==}
|
||||
engines: {node: ^10 || ^12 || >=14}
|
||||
dependencies:
|
||||
nanoid: 3.3.6
|
||||
@@ -2510,7 +2505,7 @@ packages:
|
||||
'@types/katex': 0.16.3
|
||||
hast-util-from-html-isomorphic: 2.0.0
|
||||
hast-util-to-text: 4.0.0
|
||||
katex: 0.16.8
|
||||
katex: 0.16.10
|
||||
unist-util-visit-parents: 6.0.1
|
||||
vfile: 6.0.1
|
||||
dev: false
|
||||
@@ -2999,14 +2994,6 @@ packages:
|
||||
resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==}
|
||||
dev: false
|
||||
|
||||
/watchpack@2.4.0:
|
||||
resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
dependencies:
|
||||
glob-to-regexp: 0.4.1
|
||||
graceful-fs: 4.2.11
|
||||
dev: false
|
||||
|
||||
/web-namespaces@2.0.1:
|
||||
resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==}
|
||||
dev: false
|
||||
@@ -3031,10 +3018,6 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/zod@3.21.4:
|
||||
resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==}
|
||||
dev: false
|
||||
|
||||
/zod@3.22.2:
|
||||
resolution: {integrity: sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==}
|
||||
dev: false
|
||||
|
2
go.mod
2
go.mod
@@ -32,5 +32,5 @@ require (
|
||||
golang.org/x/text v0.3.8 // indirect
|
||||
gopkg.in/ini.v1 v1.66.4 // 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/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-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
|
||||
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-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
@@ -143,6 +143,7 @@ func (b Backend) Exec(args []string) error {
|
||||
return err
|
||||
}
|
||||
options := ExecuteOptions{Envs: env}
|
||||
args = append(args, combineBackendOptions("exec", b)...)
|
||||
_, out, err := ExecuteResticCommand(options, args...)
|
||||
if err != nil {
|
||||
colors.Error.Println(out)
|
||||
@@ -182,6 +183,7 @@ func (b Backend) ExecDocker(l Location, args []string) (int, string, error) {
|
||||
case "s3":
|
||||
case "azure":
|
||||
case "gs":
|
||||
case "rest":
|
||||
// No additional setup needed
|
||||
case "rclone":
|
||||
// Read host rclone config and mount it into the container
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@@ -37,7 +36,7 @@ func dlJSON(url string) (GithubRelease, error) {
|
||||
return parsed, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return parsed, err
|
||||
|
||||
@@ -73,9 +72,10 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
|
||||
// Uncompress
|
||||
bz := bzip2.NewReader(resp.Body)
|
||||
|
||||
// Save to tmp
|
||||
// Linux does not support overwriting the file that is currently being overwritten, but it can be deleted and a new one moved in its place.
|
||||
tmp, err := ioutil.TempFile(os.TempDir(), "autorestic-")
|
||||
// Save to tmp file in the same directory as the install directory
|
||||
// Linux does not support overwriting the file that is currently being running
|
||||
// But it can be delete the old one and a new one moved in its place.
|
||||
tmp, err := os.CreateTemp(INSTALL_PATH, "autorestic-")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -89,24 +89,26 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
|
||||
|
||||
to := path.Join(INSTALL_PATH, name)
|
||||
defer os.Remove(tmp.Name()) // Cleanup temporary file after thread exits
|
||||
if err := os.Rename(tmp.Name(), to); err != 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 {
|
||||
|
||||
mode := os.FileMode(0755)
|
||||
if originalBin, err := os.Lstat(to); err == nil {
|
||||
mode = originalBin.Mode()
|
||||
err := os.Remove(to)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = os.Rename(tmp.Name(), to)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.Chmod(to, mode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
colors.Success.Printf("Successfully installed '%s' under %s\n", name, INSTALL_PATH)
|
||||
return nil
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const VERSION = "1.7.11"
|
||||
const VERSION = "1.8.2"
|
||||
|
||||
type OptionMap map[string][]interface{}
|
||||
type Options map[string]OptionMap
|
||||
@@ -132,10 +132,11 @@ func (c *Config) Describe() {
|
||||
|
||||
tmp = ""
|
||||
hooks := map[string][]string{
|
||||
"Before": l.Hooks.Before,
|
||||
"After": l.Hooks.After,
|
||||
"Failure": l.Hooks.Failure,
|
||||
"Success": l.Hooks.Success,
|
||||
"PreValidate": l.Hooks.PreValidate,
|
||||
"Before": l.Hooks.Before,
|
||||
"After": l.Hooks.After,
|
||||
"Failure": l.Hooks.Failure,
|
||||
"Success": l.Hooks.Success,
|
||||
}
|
||||
for hook, commands := range hooks {
|
||||
if len(commands) > 0 {
|
||||
|
@@ -33,11 +33,12 @@ const (
|
||||
)
|
||||
|
||||
type Hooks struct {
|
||||
Dir string `mapstructure:"dir"`
|
||||
Before HookArray `mapstructure:"before,omitempty"`
|
||||
After HookArray `mapstructure:"after,omitempty"`
|
||||
Success HookArray `mapstructure:"success,omitempty"`
|
||||
Failure HookArray `mapstructure:"failure,omitempty"`
|
||||
Dir string `mapstructure:"dir"`
|
||||
PreValidate HookArray `mapstructure:"prevalidate,omitempty"`
|
||||
Before HookArray `mapstructure:"before,omitempty"`
|
||||
After HookArray `mapstructure:"after,omitempty"`
|
||||
Success HookArray `mapstructure:"success,omitempty"`
|
||||
Failure HookArray `mapstructure:"failure,omitempty"`
|
||||
}
|
||||
|
||||
type LocationCopy = map[string][]string
|
||||
@@ -184,12 +185,18 @@ func (l Location) Backup(cron bool, specificBackend string) []error {
|
||||
},
|
||||
}
|
||||
|
||||
// Hooks before location validation
|
||||
if err := l.ExecuteHooks(l.Hooks.PreValidate, options); err != nil {
|
||||
errors = append(errors, err)
|
||||
goto after
|
||||
}
|
||||
|
||||
if err := l.validate(); err != nil {
|
||||
errors = append(errors, err)
|
||||
goto after
|
||||
}
|
||||
|
||||
// Hooks
|
||||
// Hooks after location validation
|
||||
if err := l.ExecuteHooks(l.Hooks.Before, options); err != nil {
|
||||
errors = append(errors, err)
|
||||
goto after
|
||||
@@ -289,12 +296,13 @@ func (l Location) Backup(cron bool, specificBackend string) []error {
|
||||
}
|
||||
}
|
||||
|
||||
// After hooks
|
||||
// After backup hooks
|
||||
if err := l.ExecuteHooks(l.Hooks.After, options); err != nil {
|
||||
errors = append(errors, err)
|
||||
}
|
||||
|
||||
after:
|
||||
// Success/failure hooks
|
||||
var commands []string
|
||||
var isSuccess = len(errors) == 0
|
||||
if isSuccess {
|
||||
|
Reference in New Issue
Block a user