mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-04-03 08:06:56 +00:00
Compare commits
335 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bb29a98614 | ||
|
39f4f87ce3 | ||
|
bd36bbe429 | ||
|
48fa20b482 | ||
|
f7d28b486c | ||
|
6895df1c83 | ||
|
8a773856de | ||
|
41e4e4a5f3 | ||
|
6424c64304 | ||
|
d39dafaef1 | ||
|
5a0f7e94f4 | ||
|
6a60d02759 | ||
1f7240c6a0 | |||
592d1093ac | |||
83481072bb | |||
|
776638e6fe | ||
|
bc74d3f13e | ||
|
dd01e97cf3 | ||
|
aabb0989c6 | ||
62a81d1420 | |||
e4b33cad1f | |||
|
a82273ec13 | ||
|
2418da5636 | ||
|
7508df7d66 | ||
6e34196220 | |||
|
dc56911a45 | ||
edb3ba35d8 | |||
|
12f6143bb4 | ||
|
a6bf1d1408 | ||
|
13aa560fda | ||
|
bbb1c85cad | ||
|
4cc44315ab | ||
|
b3440cd87c | ||
|
4848702929 | ||
b5604b8b9f | |||
|
24220f6b62 | ||
ced20801c1 | |||
|
ce9140fa1e | ||
|
046c79fd15 | ||
|
f8603425d1 | ||
068121d722 | |||
8eea7d33f8 | |||
|
fc8b5fdbe2 | ||
|
f67bb7f73c | ||
|
530b1b646c | ||
|
3b57602fe8 | ||
|
045513234f | ||
|
78b0db50e0 | ||
|
62dd371d51 | ||
|
08766b75db | ||
b3b7c8df95 | |||
2c5266c9a0 | |||
087b293c39 | |||
|
112a69d743 | ||
|
37d55c691f | ||
|
715b6f791c | ||
|
38b38c6805 | ||
c82db56069 | |||
27821dc3ef | |||
866975d32d | |||
|
955ac0e323 | ||
|
1512db5b55 | ||
|
046331748c | ||
72a40eaaa2 | |||
ec61effe22 | |||
d6acab94a5 | |||
|
d0d2fcf0f2 | ||
58fd41fafb | |||
|
d0c4a32879 | ||
74979e9a2a | |||
|
3732dcf6ff | ||
|
874ed52e3b | ||
4d9a2b828e | |||
|
b830667264 | ||
|
83eeb847ac | ||
|
a89ba5a40a | ||
|
6990bf6adc | ||
|
2f407cf211 | ||
489f3078fe | |||
|
e07dd0d991 | ||
|
2b9dc9f17c | ||
|
465bc037c2 | ||
|
37a043afff | ||
|
e91b632181 | ||
|
2b30998b9a | ||
|
49b37a0a9a | ||
3bc091f826 | |||
5bcf5c9217 | |||
ff2e3714d1 | |||
2e6764223d | |||
434862ed4e | |||
2da440a1cd | |||
0f6c34dc6b | |||
3457fc01bf | |||
|
1e62f6cb05 | ||
8112aceb30 | |||
|
b4cc0f0ab1 | ||
|
a3e539b0b7 | ||
|
79164e3de0 | ||
8b74a98836 | |||
8a713e497d | |||
71601ae7a6 | |||
|
85d3f06b79 | ||
5afad86e37 | |||
ba9e090695 | |||
|
05def04770 | ||
d85470459f | |||
1f69a7974a | |||
db9f5dea66 | |||
75160d4d6a | |||
92feaef5bb | |||
2a7e233cdb | |||
a373c07fb0 | |||
ec9e2aebcd | |||
7d87160706 | |||
8e1fe6af65 | |||
|
65ba1f6ac1 | ||
|
6bf4953003 | ||
27758a03fa | |||
bbdae05199 | |||
389490c4ea | |||
21b83b4c89 | |||
982f9e0b5c | |||
0c37af5588 | |||
e3c378f2a1 | |||
3b541665ae | |||
e0b2c99ccd | |||
2b14e6b1af | |||
1810af8d02 | |||
252968e15e | |||
26de4385ea | |||
0c71bea93e | |||
3029259d82 | |||
|
389f7c25dd | ||
e055e28cfe | |||
ed3c17d678 | |||
8802b74b47 | |||
e94e7030fc | |||
c55e91b8ff | |||
170bdb81ad | |||
4126436f7f | |||
113a97c283 | |||
c250391f67 | |||
d3b4915d25 | |||
cd7a5cbc13 | |||
3dd3956d64 | |||
59035da46a | |||
90914d2078 | |||
0ae374cd45 | |||
3665cea62d | |||
cf92d400c2 | |||
696bd14ac7 | |||
a68e3e426e | |||
27e82c8529 | |||
7f9251f06b | |||
09cfa4a98e | |||
05c3458a95 | |||
2826f9586d | |||
4fe241e6f3 | |||
d0b1b86fdd | |||
14dd41d60d | |||
bcfc734cd1 | |||
6817f494ef | |||
2c46f0da0c | |||
ac756dfbde | |||
f71425be5b | |||
|
d78fbb6650 | ||
7ad6f7ce9e | |||
de663f287c | |||
439076d7ab | |||
8c30134f7c | |||
11d1da7468 | |||
92b1577634 | |||
a7944aed1f | |||
3b99e301e9 | |||
246e6fc0d8 | |||
c2f9ed9204 | |||
4055ebf8e8 | |||
6be0a80b29 | |||
efd4a7dfea | |||
440609220c | |||
fb6217d868 | |||
1628384e1f | |||
3e80e6d18e | |||
83905d2993 | |||
ddc3accb30 | |||
7874512ec0 | |||
0b5f4017e4 | |||
88198c4fcb | |||
8cd759105f | |||
6137e31c3b | |||
2789502c89 | |||
b87381cd3b | |||
048a5ffed8 | |||
02a8e461d4 | |||
a1abe13a39 | |||
ddf287f6f5 | |||
56f82ae656 | |||
95b1ca3297 | |||
|
7a8830cb2f | ||
959d19cbdb | |||
9dc7763445 | |||
|
50984f6771 | ||
e80f200873 | |||
86ae70672a | |||
5c0788900f | |||
20334a7e83 | |||
7bebd04482 | |||
b9b8857bf4 | |||
dd6e618161 | |||
a4b54f9f64 | |||
c2e88193cd | |||
a2ef69d96d | |||
|
d45949b028 | ||
77d47cc697 | |||
a3239c0f3b | |||
90cd3171e5 | |||
61673bd88b | |||
41736ea3c4 | |||
a7779e04bd | |||
|
1326e7e53c | ||
478e193d78 | |||
11d4c67dce | |||
1643309957 | |||
e05386b0b5 | |||
aebaf0a225 | |||
c090013bf5 | |||
88c6949208 | |||
9256cdc38c | |||
a8c611e8ce | |||
d4522c7ffe | |||
21185d894e | |||
b119fc7ea5 | |||
|
73f4bcfd48 | ||
|
3567319314 | ||
|
bf19c983d1 | ||
|
12e4de110b | ||
c9f425ef64 | |||
974f555dff | |||
1688c1f3c3 | |||
29e46d3b5c | |||
0335abb669 | |||
b2f9b9a54e | |||
2b13a6e13d | |||
cc293ea256 | |||
a4ddd5bbcb | |||
7cbf43b75d | |||
bae77c4673 | |||
12adeb2b06 | |||
37b26dfc31 | |||
c1795b2acc | |||
b8d12e518c | |||
50060cf539 | |||
c33aac42dc | |||
c359053e0e | |||
c16340ab26 | |||
edc85c4ac3 | |||
68682777f2 | |||
|
b6c7922df5 | ||
|
991b8bec22 | ||
bbc32568ad | |||
f3c038c716 | |||
59612a97b6 | |||
33319a00ef | |||
8eb14ea14f | |||
70eb9e441f | |||
be25af2d76 | |||
1c436369f0 | |||
6efcce07b7 | |||
|
dc6dd2e712 | ||
|
68628d3776 | ||
40988ef3b4 | |||
fad33fcdaa | |||
|
8cf8a77558 | ||
36998cfd3b | |||
cf03562ea2 | |||
188560395d | |||
bacbd0f806 | |||
93bf0388a4 | |||
ec8fdbd135 | |||
420934489c | |||
|
2ba767c8c3 | ||
b489c662c7 | |||
6862529a89 | |||
aa96a95600 | |||
89e32c298c | |||
873170c6d1 | |||
ea82fea8e1 | |||
a35edcaea5 | |||
86d44eafad | |||
e927fd5a64 | |||
d5e13d4e27 | |||
824c90904c | |||
58fb5e073a | |||
541a7c2a72 | |||
e671780e54 | |||
a5471efa21 | |||
769ae4c566 | |||
f2934f60ae | |||
f6bc91e9b5 | |||
fb073627a8 | |||
976a3beab5 | |||
ec2377287e | |||
7b7eec2dba | |||
33be94ba55 | |||
8f7513b103 | |||
cf417e360d | |||
b5caad2d70 | |||
2e594cade6 | |||
276c424106 | |||
b314912821 | |||
b1054f3512 | |||
1bbd3879fe | |||
aa0b81023f | |||
09e0ee4dec | |||
952334fecb | |||
a45eee6009 | |||
a658b6bb21 | |||
8e13e7bc40 | |||
6449b8999f | |||
da6d9c53aa | |||
604354741e | |||
3ccaee4066 | |||
640b60c47f | |||
d293e93fa8 | |||
03ca0c8677 | |||
19e75c1dad | |||
6e25b90915 | |||
8a1fe41825 | |||
5d92b5bcc1 | |||
05be58a3a7 | |||
9ba58ee7f8 | |||
335724cce7 | |||
43244302be | |||
03cbbfd91c |
@ -1,15 +0,0 @@
|
||||
import { build } from '@codedoc/core';
|
||||
|
||||
import { config } from './config';
|
||||
import { installTheme$ } from './content/theme';
|
||||
import { content } from './content';
|
||||
|
||||
|
||||
build(config, content, installTheme$, {
|
||||
resolve: {
|
||||
modules: ['.codedoc/node_modules']
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: ['.codedoc/node_modules']
|
||||
}
|
||||
});
|
@ -1,24 +0,0 @@
|
||||
import { configuration } from '@codedoc/core'
|
||||
|
||||
export const config = configuration({
|
||||
src: {
|
||||
base: 'docs',
|
||||
},
|
||||
dest: {
|
||||
html: './build',
|
||||
assets: './build',
|
||||
bundle: './_',
|
||||
styles: './_',
|
||||
},
|
||||
page: {
|
||||
title: {
|
||||
base: 'Autorestic',
|
||||
},
|
||||
},
|
||||
misc: {
|
||||
github: {
|
||||
user: 'cupcakearmy',
|
||||
repo: 'autorestic',
|
||||
},
|
||||
},
|
||||
})
|
@ -1,19 +0,0 @@
|
||||
import { CodedocConfig } from '@codedoc/core';
|
||||
import { Footer as _Footer, GitterToggle$, Watermark} from '@codedoc/core/components';
|
||||
|
||||
|
||||
export function Footer(config: CodedocConfig, renderer: any) {
|
||||
let github$;
|
||||
if (config.misc?.github)
|
||||
github$ = <a href={`https://github.com/${config.misc.github.user}/${config.misc.github.repo}/`}
|
||||
target="_blank">GitHub</a>;
|
||||
|
||||
let community$;
|
||||
if (config.misc?.gitter)
|
||||
community$ = <GitterToggle$ room={config.misc.gitter.room}/>
|
||||
|
||||
if (github$ && community$) return <_Footer>{github$}<hr/>{community$}</_Footer>;
|
||||
else if (github$) return <_Footer>{github$}</_Footer>;
|
||||
else if (community$) return <_Footer>{community$}</_Footer>;
|
||||
else return <_Footer><Watermark/></_Footer>;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
import { CodedocConfig } from '@codedoc/core';
|
||||
import { Header as _Header, GithubButton, Watermark } from '@codedoc/core/components';
|
||||
|
||||
|
||||
export function Header(config: CodedocConfig, renderer: any) {
|
||||
return (
|
||||
<_Header>{config.misc?.github ?
|
||||
<fragment>
|
||||
<GithubButton action={config.misc.github.action || 'Star'}
|
||||
repo={config.misc.github.repo}
|
||||
user={config.misc.github.user}
|
||||
large={config.misc.github.large === true}
|
||||
count={config.misc.github.count !== false}
|
||||
standardIcon={config.misc.github.standardIcon !== false}/>
|
||||
<br/><br/>
|
||||
</fragment>
|
||||
: ''}
|
||||
<Watermark/>
|
||||
</_Header>
|
||||
)
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
import { RendererLike } from '@connectv/html'
|
||||
import { File } from 'rxline/fs'
|
||||
import {
|
||||
Page,
|
||||
Meta,
|
||||
ContentNav,
|
||||
Fonts,
|
||||
ToC,
|
||||
GithubSearch$,
|
||||
} from '@codedoc/core/components'
|
||||
|
||||
import { config } from '../config'
|
||||
import { Header } from './header'
|
||||
import { Footer } from './footer'
|
||||
|
||||
export function content(
|
||||
_content: HTMLElement,
|
||||
toc: HTMLElement,
|
||||
renderer: RendererLike<any, any>,
|
||||
file: File<string>
|
||||
) {
|
||||
return (
|
||||
<Page
|
||||
title={config.page.title.extractor(_content, config, file)}
|
||||
favicon={config.page.favicon}
|
||||
meta={<Meta {...config.page.meta} />}
|
||||
fonts={<Fonts {...config.page.fonts} />}
|
||||
scripts={config.page.scripts}
|
||||
stylesheets={config.page.stylesheets}
|
||||
header={<Header {...config} />}
|
||||
footer={<Footer {...config} />}
|
||||
toc={
|
||||
<ToC
|
||||
default={'open'}
|
||||
search={
|
||||
config.misc?.github ? (
|
||||
<GithubSearch$
|
||||
repo={config.misc.github.repo}
|
||||
user={config.misc.github.user}
|
||||
root={config.src.base}
|
||||
pick={config.src.pick.source}
|
||||
drop={config.src.drop.source}
|
||||
/>
|
||||
) : (
|
||||
false
|
||||
)
|
||||
}
|
||||
>
|
||||
{toc}
|
||||
</ToC>
|
||||
}
|
||||
>
|
||||
{_content}
|
||||
<ContentNav content={_content} />
|
||||
</Page>
|
||||
)
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import { funcTransport } from '@connectv/sdh/transport';
|
||||
import { useTheme } from '@codedoc/core/transport';
|
||||
|
||||
import { theme } from '../theme';
|
||||
|
||||
|
||||
export function installTheme() { useTheme(theme); }
|
||||
export const installTheme$ = /*#__PURE__*/funcTransport(installTheme);
|
4739
.codedoc/package-lock.json
generated
4739
.codedoc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@codedoc/core": "^0.2.15"
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
import { join } from 'path';
|
||||
import { serve } from '@codedoc/core';
|
||||
|
||||
import { config } from './config';
|
||||
import { content } from './content';
|
||||
import { installTheme$ } from './content/theme';
|
||||
|
||||
|
||||
const root = join(__dirname, '../');
|
||||
|
||||
serve(root, config, content, installTheme$, {
|
||||
resolve: {
|
||||
modules: ['.codedoc/node_modules']
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: ['.codedoc/node_modules']
|
||||
}
|
||||
});
|
@ -1,11 +0,0 @@
|
||||
import { createTheme } from '@codedoc/core/transport';
|
||||
|
||||
|
||||
export const theme = /*#__PURE__*/createTheme({
|
||||
light: {
|
||||
primary: '#1eb2a6'
|
||||
},
|
||||
dark: {
|
||||
primary: '#1eb2a6'
|
||||
}
|
||||
});
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"declaration": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"sourceMap": true,
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"jsx": "react",
|
||||
"jsxFactory": "renderer.create",
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"./**/*"
|
||||
]
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import { exec, spawn } from 'child_process';
|
||||
import { config } from './config';
|
||||
|
||||
|
||||
const cmd = 'ts-node-dev';
|
||||
const params = `--project .codedoc/tsconfig.json`
|
||||
+ ` -T --watch ${config.src.base},.codedoc`
|
||||
+ ` --ignore-watch .codedoc/node_modules`
|
||||
+ ` .codedoc/serve`;
|
||||
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
const child = exec(cmd + ' ' + params);
|
||||
|
||||
child.stdout?.pipe(process.stdout);
|
||||
child.stderr?.pipe(process.stderr);
|
||||
child.on('close', () => {});
|
||||
}
|
||||
else {
|
||||
const child = spawn(cmd, [params], { stdio: 'inherit', shell: 'bash' });
|
||||
child.on('close', () => {});
|
||||
}
|
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
*
|
||||
!**/*.go
|
||||
!build
|
||||
!cmd
|
||||
!internal
|
||||
!go.*
|
8
.github/dependabot.yml
vendored
Normal file
8
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
51
.github/workflows/build.yml
vendored
Normal file
51
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
name: Main
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Docker Labels
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v4
|
||||
with:
|
||||
images: cupcakearmy/autorestic
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.21'
|
||||
- name: Build
|
||||
run: go run build/build.go
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: dist/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
24
.github/workflows/ci.yml
vendored
Normal file
24
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: CI
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.21'
|
||||
- run: go test -v ./...
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.21'
|
||||
- run: go build -v .
|
23
.gitignore
vendored
23
.gitignore
vendored
@ -2,20 +2,11 @@
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
# Node
|
||||
node_modules/
|
||||
|
||||
# Build & Runtime
|
||||
bin
|
||||
lib
|
||||
data
|
||||
restore
|
||||
docker
|
||||
Dockerfile
|
||||
build
|
||||
dist
|
||||
|
||||
# Config
|
||||
.autorestic.yml
|
||||
.autorestic.lock
|
||||
.docker.yml
|
||||
.autorestic*
|
||||
|
||||
# Build & Dev
|
||||
test
|
||||
autorestic
|
||||
data
|
||||
dist
|
@ -1,4 +0,0 @@
|
||||
semi: false
|
||||
singleQuote: true
|
||||
trailingComma: 'es5'
|
||||
printWidth: 150
|
283
CHANGELOG.md
283
CHANGELOG.md
@ -1,3 +1,282 @@
|
||||
## 0.27
|
||||
# Changelog
|
||||
|
||||
- fix locking issue
|
||||
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.7.4] - 2023-01-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Transformer for extracting information. @11mariom
|
||||
|
||||
### Changed
|
||||
|
||||
- Bump docker restic version.
|
||||
- Docs dependencies updated.
|
||||
|
||||
## [1.7.1] - 2022-04-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- #178 Lean flag not working properly.
|
||||
|
||||
## [1.7.0] - 2022-04-27
|
||||
|
||||
### Changed
|
||||
|
||||
- #147 Stream output instead of buffering.
|
||||
|
||||
### Fixed
|
||||
|
||||
- #184 duplicate global options.
|
||||
- #154 add docs for migration.
|
||||
- #182 fix bug with upgrading custom restic with custom path.
|
||||
|
||||
## [1.6.2] - 2022-04-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Version bump in code.
|
||||
|
||||
## [1.6.1] - 2022-04-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bump go version in docker file to 18.
|
||||
|
||||
## [1.6.0] - 2022-04-14
|
||||
|
||||
### Added
|
||||
|
||||
- support for copy command #145
|
||||
- partial restore with `--include`, `--exclude`, `--iinclude`, `--iexclude` flags #161
|
||||
- run forget automatically after backup #158
|
||||
- exit codes to hooks as env variable #142
|
||||
|
||||
### Fixed
|
||||
|
||||
- Lean flag not removing all output #178
|
||||
|
||||
## [1.5.8] - 2022-03-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Better error handling for bad config files.
|
||||
|
||||
## [1.5.7] - 2022-03-11
|
||||
|
||||
### Added
|
||||
|
||||
- SSH in docker image. @fariszr
|
||||
|
||||
### Security
|
||||
|
||||
- Updated dependencies
|
||||
|
||||
## [1.5.6] - 2022-03-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- Add bash in docker image for hooks. @fariszr
|
||||
|
||||
## [1.5.5] - 2022-02-16
|
||||
|
||||
### Changed
|
||||
|
||||
- Go version was updated from `1.16` to `1.17`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Home directory was not being taken into account for loading configs.
|
||||
|
||||
## [1.5.4] - 2022-02-16
|
||||
|
||||
### Fixed
|
||||
|
||||
- Lean flag not omitting all output.
|
||||
|
||||
## [1.5.3] - 2022-02-16
|
||||
|
||||
### Fixed
|
||||
|
||||
- Error throwing not finding config even it's not being used.
|
||||
|
||||
## [1.5.2] - 2022-02-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- Config loading @jjromannet
|
||||
- Making a backup of the file @jjromannet
|
||||
|
||||
## [1.5.1] - 2021-12-06
|
||||
|
||||
### Changed
|
||||
|
||||
- use official docker image instead of installing rclone every time docker is used.
|
||||
- docker docs
|
||||
|
||||
### Fixed
|
||||
|
||||
- lock file not always next to the config file.
|
||||
- update / install bugs.
|
||||
- lock docker image tag to the current autorestic version
|
||||
- better error logging
|
||||
|
||||
## [1.5.0] - 2021-11-20
|
||||
|
||||
### Added
|
||||
|
||||
- Support for multiple paths.
|
||||
- Improved error handling.
|
||||
- Allow for specific snapshot to be restored.
|
||||
- Docker image.
|
||||
|
||||
### Fixed
|
||||
|
||||
- rclone in docker volumes.
|
||||
|
||||
### Changed
|
||||
|
||||
- [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.
|
||||
|
||||
## [1.4.1] - 2021-10-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- Numeric values from config files not being passed to env.
|
||||
|
||||
## [1.4.0] - 2021-10-30
|
||||
|
||||
### Added
|
||||
|
||||
- Allow specify to specify a backend for location backup.
|
||||
- Global restic flags.
|
||||
- Generic ENV support for backends.
|
||||
|
||||
### Changed
|
||||
|
||||
- Install now only requires `wget`.
|
||||
- Env variable for the `KEY` has been renamed from `AUTORESTIC_[BACKEND NAME]_KEY` -> `AUTORESTIC_[BACKEND NAME]_RESTIC_PASSWORD`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Error handling during upgrade & uninstall.
|
||||
|
||||
## [1.3.0] - 2021-10-26
|
||||
|
||||
### Added
|
||||
|
||||
- Pass restic backup metadata as ENV to hooks.
|
||||
- Support for `XDG_CONFIG_HOME` and `${HOME}/.config` as default locations for `.autorestic.yaml` file.
|
||||
- Binary restic flags are now supported.
|
||||
- Pass encryption keys from env variables or files.
|
||||
|
||||
## [1.2.0] - 2021-08-05
|
||||
|
||||
### Added
|
||||
|
||||
- Community page
|
||||
- Support for yaml references and aliases.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Better verbose output for hooks.
|
||||
- Better error message for bad formatted configs.
|
||||
|
||||
## [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
|
||||
|
||||
- use custom restic binary.
|
||||
- success & failure hooks.
|
||||
|
||||
### Fixed
|
||||
|
||||
- don't skip other locations on failure.
|
||||
|
||||
## [1.0.9] - 2021-05-01
|
||||
|
||||
### Fixed
|
||||
|
||||
- Validation for docker volumes.
|
||||
|
||||
## [1.0.8] - 2021-04-28
|
||||
|
||||
### Added
|
||||
|
||||
- `--lean` flag to cron command for less output about skipping backups.
|
||||
|
||||
### Fixed
|
||||
|
||||
- consistent lower casing in usage descriptions.
|
||||
|
||||
## [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
|
||||
|
||||
### Added
|
||||
|
||||
- Options to add rest username and password in config.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Don't add empty strings when saving config.
|
||||
|
||||
## [1.0.3] - 2021-04-20
|
||||
|
||||
### Fixed
|
||||
|
||||
- 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
|
||||
|
||||
### Added
|
||||
|
||||
- Add the `cron` tag to backup to backups made with cron.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Don't unlock lockfile if process is already running.
|
||||
|
||||
## [1.0.1] - 2021-04-17
|
||||
|
||||
### Added
|
||||
|
||||
- Completion command for various shells.
|
||||
|
||||
## [1.0.0] - 2021-04-17
|
||||
|
||||
- Rewrite in go. See https://autorestic.vercel.app/upgrade for migration.
|
||||
|
30
DEVELOPMENT.md
Normal file
30
DEVELOPMENT.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Development
|
||||
|
||||
## Coding
|
||||
|
||||
The easiest way (imo) is to run [`gowatch`](https://github.com/silenceper/gowatch) in a separate terminal and the simply run `./autorestic ...`. `gowatch` will watch the code and automatically rebuild the binary when changes are saved to disk.
|
||||
|
||||
## Building
|
||||
|
||||
```bash
|
||||
go run build/build.go
|
||||
```
|
||||
|
||||
This will build and compress binaries for multiple platforms. The output will be put in the `dist` folder.
|
||||
|
||||
## Releasing
|
||||
|
||||
Releases are automatically built by the github workflow and uploaded to the release.
|
||||
|
||||
1. Bump `VERSION` in `internal/config.go`.
|
||||
2. Update `CHANGELOG.md`
|
||||
3. Commit to master
|
||||
4. Create a new release with the `v1.2.3` tag and mark as pre-release.
|
||||
5. The Github action will build the binaries, upload and mark the release as ready when done.
|
||||
|
||||
### Brew
|
||||
|
||||
1. Download the latest release.
|
||||
2. Check the checksum with `shasum -a 256 autorestic-1.2.3.tar.gz`
|
||||
3. Update `url` and `sha256` in the brew repo.
|
||||
4. Submit PR
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM golang:1.24-alpine as builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY go.* .
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN go build
|
||||
|
||||
FROM restic/restic:0.17.3
|
||||
RUN apk add --no-cache rclone bash curl docker-cli
|
||||
COPY --from=builder /app/autorestic /usr/bin/autorestic
|
||||
ENTRYPOINT []
|
||||
CMD [ "autorestic" ]
|
215
LICENSE
215
LICENSE
@ -1,21 +1,202 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Nicco
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
1. Definitions.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
33
README.md
33
README.md
@ -10,16 +10,41 @@
|
||||
Config driven, easy backup cli for <a href="https://restic.net/">restic</a>.
|
||||
<br>
|
||||
<strong><a href="https://autorestic.vercel.app/">»»» Docs & Getting Started »»»</a></strong>
|
||||
<br><br>
|
||||
<a target="_blank" href="https://discord.gg/wS7RpYTYd2">
|
||||
<img src="https://img.shields.io/discord/252403122348097536" alt="discord badge" />
|
||||
<img src="https://img.shields.io/github/contributors/cupcakearmy/autorestic" alt="contributor badge" />
|
||||
<img src="https://img.shields.io/github/downloads/cupcakearmy/autorestic/total" alt="downloads badge" />
|
||||
<img src="https://img.shields.io/github/v/release/cupcakearmy/autorestic" alt="version badge" />
|
||||
</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
### Why / What?
|
||||
### 💭 Why / What?
|
||||
|
||||
Autorestic is a wrapper around the amazing [restic](https://restic.net/). While being amazing the restic cli can be a bit overwhelming and difficult to manage if you have many different location that you want to backup to multiple locations. This utility is aimed at making this easier 🙂
|
||||
Autorestic is a wrapper around the amazing [restic](https://restic.net/). While being amazing the restic cli can be a bit overwhelming and difficult to manage if you have many different locations that you want to backup to multiple locations. This utility is aimed at making this easier 🙂.
|
||||
|
||||
### Questions / Support
|
||||
### 🌈 Features
|
||||
|
||||
Check the [discussions page](https://github.com/cupcakearmy/autorestic/discussions)
|
||||
- YAML config files, no CLI
|
||||
- Incremental -> Minimal space is used
|
||||
- Backup locations to multiple backends
|
||||
- Snapshot policies and pruning
|
||||
- Fully encrypted
|
||||
- Before/after backup hooks
|
||||
- Exclude pattern/files
|
||||
- Cron jobs for automatic backup
|
||||
- Backup & Restore docker volume
|
||||
- Generated completions for `[bash|zsh|fish|powershell]`
|
||||
|
||||
### ❓ Questions / Support
|
||||
|
||||
Check the [discussions page](https://github.com/cupcakearmy/autorestic/discussions) or [join on discord](https://discord.gg/wS7RpYTYd2)
|
||||
|
||||
## Contributing / Developing
|
||||
|
||||
PRs, feature requests, etc. are welcomed :)
|
||||
Have a look at [the dev docs](./DEVELOPMENT.md)
|
||||
|
@ -1,9 +0,0 @@
|
||||
# Releasing
|
||||
|
||||
Releases are handled by the CD server with includes checksums for each binary.
|
||||
|
||||
```bash
|
||||
git tag 0.x
|
||||
git push
|
||||
git push origin --tags
|
||||
```
|
132
build/build.go
Normal file
132
build/build.go
Normal file
@ -0,0 +1,132 @@
|
||||
// Heavily inspired (copied) by the restic build file
|
||||
// https://github.com/restic/restic/blob/aa0faa8c7d7800b6ba7b11164fa2d3683f7f78aa/helpers/build-release-binaries/main.go#L225
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/sha1"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
)
|
||||
|
||||
var DIR, _ = filepath.Abs("./dist")
|
||||
|
||||
var targets = map[string][]string{
|
||||
// "aix": {"ppc64"}, // Not supported by fsnotify
|
||||
"darwin": {"amd64", "arm64"},
|
||||
"freebsd": {"386", "amd64", "arm"},
|
||||
"linux": {"386", "amd64", "arm", "arm64", "ppc64le", "mips", "mipsle", "mips64", "mips64le", "s390x"},
|
||||
"netbsd": {"386", "amd64"},
|
||||
"openbsd": {"386", "amd64"},
|
||||
// "windows": {"386", "amd64"}, // Not supported by autorestic
|
||||
"solaris": {"amd64"},
|
||||
}
|
||||
|
||||
type buildOptions struct {
|
||||
Target, Arch, Version string
|
||||
}
|
||||
|
||||
const (
|
||||
CHECKSUM_MD5 = "MD5SUMS"
|
||||
CHECKSUM_SHA_1 = "SHA1SUMS"
|
||||
CHECKSUM_SHA_256 = "SHA256SUMS"
|
||||
)
|
||||
|
||||
type Checksums struct {
|
||||
filename, md5, sha1, sha256 string
|
||||
}
|
||||
|
||||
func writeChecksums(checksums *[]Checksums) {
|
||||
FILE_MD5, _ := os.OpenFile(path.Join(DIR, CHECKSUM_MD5), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||
defer FILE_MD5.Close()
|
||||
FILE_SHA1, _ := os.OpenFile(path.Join(DIR, CHECKSUM_SHA_1), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||
defer FILE_SHA1.Close()
|
||||
FILE_SHA256, _ := os.OpenFile(path.Join(DIR, CHECKSUM_SHA_256), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||
defer FILE_SHA256.Close()
|
||||
|
||||
for _, checksum := range *checksums {
|
||||
fmt.Fprintf(FILE_MD5, "%s %s\n", checksum.md5, checksum.filename)
|
||||
fmt.Fprintf(FILE_SHA1, "%s %s\n", checksum.sha1, checksum.filename)
|
||||
fmt.Fprintf(FILE_SHA256, "%s %s\n", checksum.sha256, checksum.filename)
|
||||
}
|
||||
}
|
||||
|
||||
func build(options buildOptions, wg *sync.WaitGroup, checksums *[]Checksums) {
|
||||
defer wg.Done()
|
||||
|
||||
fmt.Printf("Building: %s %s\n", options.Target, options.Arch)
|
||||
out := fmt.Sprintf("autorestic_%s_%s_%s", options.Version, options.Target, options.Arch)
|
||||
out = path.Join(DIR, out)
|
||||
|
||||
// Build
|
||||
{
|
||||
c := exec.Command("go", "build", "-o", out, "./main.go")
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
c.Env = append(os.Environ(),
|
||||
"CGO_ENABLED=0",
|
||||
"GOOS="+options.Target,
|
||||
"GOARCH="+options.Arch,
|
||||
)
|
||||
err := c.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Compress
|
||||
{
|
||||
c := exec.Command("bzip2", out)
|
||||
c.Dir = DIR
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
err := c.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Checksum
|
||||
{
|
||||
file := out + ".bz2"
|
||||
content, _ := ioutil.ReadFile(file)
|
||||
*checksums = append(*checksums, Checksums{
|
||||
filename: path.Base(file),
|
||||
md5: fmt.Sprintf("%x", md5.Sum(content)),
|
||||
sha1: fmt.Sprintf("%x", sha1.Sum(content)),
|
||||
sha256: fmt.Sprintf("%x", sha256.Sum256(content)),
|
||||
})
|
||||
}
|
||||
|
||||
fmt.Printf("Built: %s\n", path.Base(out))
|
||||
}
|
||||
|
||||
func main() {
|
||||
os.RemoveAll(DIR)
|
||||
v := internal.VERSION
|
||||
checksums := []Checksums{}
|
||||
|
||||
// Build async
|
||||
var wg sync.WaitGroup
|
||||
for target, archs := range targets {
|
||||
for _, arch := range archs {
|
||||
wg.Add(1)
|
||||
go build(buildOptions{
|
||||
Target: target,
|
||||
Arch: arch,
|
||||
Version: v,
|
||||
}, &wg, &checksums)
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
writeChecksums(&checksums)
|
||||
}
|
50
cmd/backup.go
Normal file
50
cmd/backup.go
Normal file
@ -0,0 +1,50 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var backupCmd = &cobra.Command{
|
||||
Use: "backup",
|
||||
Short: "Create backups for given locations",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
err := lock.Lock()
|
||||
CheckErr(err)
|
||||
defer lock.Unlock()
|
||||
dry, _ := cmd.Flags().GetBool("dry-run")
|
||||
|
||||
selected, err := internal.GetAllOrSelected(cmd, false)
|
||||
CheckErr(err)
|
||||
|
||||
errors := 0
|
||||
for _, name := range selected {
|
||||
var splitted = strings.Split(name, "@")
|
||||
var specificBackend = ""
|
||||
if len(splitted) > 1 {
|
||||
specificBackend = splitted[1]
|
||||
}
|
||||
location, _ := internal.GetLocation(splitted[0])
|
||||
errs := location.Backup(false, dry, specificBackend)
|
||||
for _, err := range errs {
|
||||
colors.Error.Printf("%s\n\n", err)
|
||||
errors++
|
||||
}
|
||||
}
|
||||
if errors > 0 {
|
||||
CheckErr(fmt.Errorf("%d errors were found", errors))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(backupCmd)
|
||||
internal.AddFlagsToCommand(backupCmd, false)
|
||||
backupCmd.Flags().Bool("dry-run", false, "do not write changes, show what would be affected")
|
||||
}
|
27
cmd/check.go
Normal file
27
cmd/check.go
Normal file
@ -0,0 +1,27 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var checkCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "Check if everything is setup",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
err := lock.Lock()
|
||||
CheckErr(err)
|
||||
defer lock.Unlock()
|
||||
|
||||
CheckErr(internal.CheckConfig())
|
||||
|
||||
colors.Success.Println("Everything is fine.")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(checkCmd)
|
||||
}
|
70
cmd/completion.go
Normal file
70
cmd/completion.go
Normal file
@ -0,0 +1,70 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var completionCmd = &cobra.Command{
|
||||
Use: "completion [bash|zsh|fish|powershell]",
|
||||
Short: "Generate completion script",
|
||||
Long: `To load completions:
|
||||
|
||||
Bash:
|
||||
|
||||
$ source <(autorestic completion bash)
|
||||
|
||||
# To load completions for each session, execute once:
|
||||
# Linux:
|
||||
$ autorestic completion bash > /etc/bash_completion.d/autorestic
|
||||
# macOS:
|
||||
$ autorestic completion bash > /usr/local/etc/bash_completion.d/autorestic
|
||||
|
||||
Zsh:
|
||||
|
||||
# If shell completion is not already enabled in your environment,
|
||||
# you will need to enable it. You can execute the following once:
|
||||
|
||||
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
|
||||
|
||||
# To load completions for each session, execute once:
|
||||
$ autorestic completion zsh > "${fpath[1]}/_autorestic"
|
||||
|
||||
# You will need to start a new shell for this setup to take effect.
|
||||
|
||||
fish:
|
||||
|
||||
$ autorestic completion fish | source
|
||||
|
||||
# To load completions for each session, execute once:
|
||||
$ autorestic completion fish > ~/.config/fish/completions/autorestic.fish
|
||||
|
||||
PowerShell:
|
||||
|
||||
PS> autorestic completion powershell | Out-String | Invoke-Expression
|
||||
|
||||
# To load completions for every new session, run:
|
||||
PS> autorestic completion powershell > autorestic.ps1
|
||||
# and source this file from your PowerShell profile.
|
||||
`,
|
||||
DisableFlagsInUseLine: true,
|
||||
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
||||
Args: cobra.ExactValidArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
switch args[0] {
|
||||
case "bash":
|
||||
cmd.Root().GenBashCompletion(os.Stdout)
|
||||
case "zsh":
|
||||
cmd.Root().GenZshCompletion(os.Stdout)
|
||||
case "fish":
|
||||
cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||
case "powershell":
|
||||
cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(completionCmd)
|
||||
}
|
28
cmd/cron.go
Normal file
28
cmd/cron.go
Normal file
@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/flags"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var cronCmd = &cobra.Command{
|
||||
Use: "cron",
|
||||
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.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
err := lock.Lock()
|
||||
CheckErr(err)
|
||||
defer lock.Unlock()
|
||||
|
||||
err = internal.RunCron()
|
||||
CheckErr(err)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(cronCmd)
|
||||
cronCmd.Flags().BoolVar(&flags.CRON_LEAN, "lean", false, "only output information about actual backups")
|
||||
}
|
47
cmd/exec.go
Normal file
47
cmd/exec.go
Normal file
@ -0,0 +1,47 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var execCmd = &cobra.Command{
|
||||
Use: "exec",
|
||||
Short: "Execute arbitrary native restic commands for given backends",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
err := lock.Lock()
|
||||
CheckErr(err)
|
||||
defer lock.Unlock()
|
||||
|
||||
selected, err := internal.GetAllOrSelected(cmd, true)
|
||||
CheckErr(err)
|
||||
|
||||
var errors []error
|
||||
for _, name := range selected {
|
||||
colors.PrimaryPrint(" Executing on \"%s\" ", name)
|
||||
backend, _ := internal.GetBackend(name)
|
||||
err := backend.Exec(args)
|
||||
if err != nil {
|
||||
errors = append(errors, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(errors) > 0 {
|
||||
for _, err := range errors {
|
||||
colors.Error.Printf("%s\n\n", err)
|
||||
}
|
||||
|
||||
CheckErr(fmt.Errorf("%d errors were found", len(errors)))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(execCmd)
|
||||
internal.AddFlagsToCommand(execCmd, true)
|
||||
}
|
35
cmd/forget.go
Normal file
35
cmd/forget.go
Normal file
@ -0,0 +1,35 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var forgetCmd = &cobra.Command{
|
||||
Use: "forget",
|
||||
Short: "Forget and optionally prune snapshots according the specified policies",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
err := lock.Lock()
|
||||
CheckErr(err)
|
||||
defer lock.Unlock()
|
||||
|
||||
selected, err := internal.GetAllOrSelected(cmd, false)
|
||||
CheckErr(err)
|
||||
prune, _ := cmd.Flags().GetBool("prune")
|
||||
dry, _ := cmd.Flags().GetBool("dry-run")
|
||||
for _, name := range selected {
|
||||
location, _ := internal.GetLocation(name)
|
||||
err := location.Forget(prune, dry)
|
||||
CheckErr(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(forgetCmd)
|
||||
internal.AddFlagsToCommand(forgetCmd, false)
|
||||
forgetCmd.Flags().Bool("prune", false, "also prune repository")
|
||||
forgetCmd.Flags().Bool("dry-run", false, "do not write changes, show what would be affected")
|
||||
}
|
18
cmd/info.go
Normal file
18
cmd/info.go
Normal file
@ -0,0 +1,18 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var infoCmd = &cobra.Command{
|
||||
Use: "info",
|
||||
Short: "Show info about the config",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig().Describe()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(infoCmd)
|
||||
}
|
19
cmd/install.go
Normal file
19
cmd/install.go
Normal file
@ -0,0 +1,19 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal/bins"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var installCmd = &cobra.Command{
|
||||
Use: "install",
|
||||
Short: "Install restic if missing",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := bins.InstallRestic()
|
||||
CheckErr(err)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(installCmd)
|
||||
}
|
63
cmd/restore.go
Normal file
63
cmd/restore.go
Normal file
@ -0,0 +1,63 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var restoreCmd = &cobra.Command{
|
||||
Use: "restore [snapshot id]",
|
||||
Short: "Restore backup for location",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
internal.GetConfig()
|
||||
err := lock.Lock()
|
||||
CheckErr(err)
|
||||
defer lock.Unlock()
|
||||
|
||||
location, _ := cmd.Flags().GetString("location")
|
||||
l, ok := internal.GetLocation(location)
|
||||
if !ok {
|
||||
CheckErr(fmt.Errorf("invalid location \"%s\"", location))
|
||||
}
|
||||
target, _ := cmd.Flags().GetString("to")
|
||||
from, _ := cmd.Flags().GetString("from")
|
||||
force, _ := cmd.Flags().GetBool("force")
|
||||
snapshot := ""
|
||||
if len(args) > 0 {
|
||||
snapshot = args[0]
|
||||
}
|
||||
|
||||
// Get optional flags
|
||||
optional := []string{}
|
||||
for _, flag := range []string{"include", "exclude", "iinclude", "iexclude"} {
|
||||
values, err := cmd.Flags().GetStringSlice(flag)
|
||||
if err == nil {
|
||||
for _, value := range values {
|
||||
optional = append(optional, "--"+flag, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = l.Restore(target, from, force, snapshot, optional)
|
||||
CheckErr(err)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(restoreCmd)
|
||||
restoreCmd.Flags().BoolP("force", "f", false, "Force, target folder will be overwritten")
|
||||
restoreCmd.Flags().String("from", "", "Which backend to use")
|
||||
restoreCmd.Flags().String("to", "", "Where to restore the data")
|
||||
restoreCmd.Flags().StringP("location", "l", "", "Location to be restored")
|
||||
restoreCmd.MarkFlagRequired("location")
|
||||
|
||||
// Passed on flags
|
||||
restoreCmd.Flags().StringSliceP("include", "i", []string{}, "Include a pattern")
|
||||
restoreCmd.Flags().StringSliceP("exclude", "e", []string{}, "Exclude a pattern")
|
||||
restoreCmd.Flags().StringSlice("iinclude", []string{}, "Include a pattern, case insensitive")
|
||||
restoreCmd.Flags().StringSlice("iexclude", []string{}, "Exclude a pattern, case insensitive")
|
||||
}
|
92
cmd/root.go
Normal file
92
cmd/root.go
Normal file
@ -0,0 +1,92 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/cupcakearmy/autorestic/internal"
|
||||
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||
"github.com/cupcakearmy/autorestic/internal/flags"
|
||||
"github.com/cupcakearmy/autorestic/internal/lock"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func CheckErr(err error) {
|
||||
if err != nil {
|
||||
colors.Error.Fprintln(os.Stderr, "Error:", err)
|
||||
lock.Unlock()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
var cfgFile string
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Version: internal.VERSION,
|
||||
Use: "autorestic",
|
||||
Short: "CLI Wrapper for restic",
|
||||
Long: "Documentation:\thttps://autorestic.vercel.app\nSupport:\thttps://discord.gg/wS7RpYTYd2",
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
CheckErr(rootCmd.Execute())
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.autorestic.yml or ./.autorestic.yml)")
|
||||
rootCmd.PersistentFlags().BoolVar(&flags.CI, "ci", false, "CI mode disabled interactive mode and colors and enables verbosity")
|
||||
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.DOCKER_IMAGE, "docker-image", "cupcakearmy/autorestic:"+internal.VERSION, "specify a custom docker image")
|
||||
cobra.OnInitialize(initConfig)
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
if ci, _ := rootCmd.Flags().GetBool("ci"); ci {
|
||||
colors.DisableColors(true)
|
||||
flags.VERBOSE = true
|
||||
}
|
||||
|
||||
if cfgFile != "" {
|
||||
viper.SetConfigFile(cfgFile)
|
||||
viper.AutomaticEnv()
|
||||
if viper.ConfigFileUsed() == "" {
|
||||
colors.Error.Printf("cannot read config file %s\n", cfgFile)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
configPaths := getConfigPaths()
|
||||
for _, cfgPath := range configPaths {
|
||||
viper.AddConfigPath(cfgPath)
|
||||
}
|
||||
if flags.VERBOSE {
|
||||
colors.Faint.Printf("Using config paths: %s\n", strings.Join(configPaths, " "))
|
||||
}
|
||||
cfgFileName := ".autorestic"
|
||||
viper.SetConfigName(cfgFileName)
|
||||
viper.AutomaticEnv()
|
||||
}
|
||||
}
|
||||
|
||||
func getConfigPaths() []string {
|
||||
result := []string{"."}
|
||||
if home, err := homedir.Dir(); err == nil {
|
||||
result = append(result, home)
|
||||
}
|
||||
|
||||
{
|
||||
xdgConfigHome, found := os.LookupEnv("XDG_CONFIG_HOME")
|
||||
if !found {
|
||||
if home, err := homedir.Dir(); err == nil {
|
||||
xdgConfigHome = filepath.Join(home, ".config")
|
||||
}
|
||||
}
|
||||
xdgConfig := filepath.Join(xdgConfigHome, "autorestic")
|
||||
result = append(result, xdgConfig)
|
||||
}
|
||||
return result
|
||||
}
|
36
cmd/root_test.go
Normal file
36
cmd/root_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const xdgConfigHome = "XDG_CONFIG_HOME"
|
||||
|
||||
func assertContains(t *testing.T, array []string, element string) {
|
||||
if !slices.Contains(array, element) {
|
||||
t.Errorf("Expected %s to be contained in %s", element, array)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigResolving(t *testing.T) {
|
||||
t.Run("~/.config/autorestic is used if XDG_CONFIG_HOME is not set", func(t *testing.T) {
|
||||
// Override env using testing so that env gets restored after test
|
||||
t.Setenv(xdgConfigHome, "")
|
||||
_ = os.Unsetenv("XDG_CONFIG_HOME")
|
||||
configPaths := getConfigPaths()
|
||||
homeDir, _ := homedir.Dir()
|
||||
expectedConfigPath := filepath.Join(homeDir, ".config/autorestic")
|
||||
assertContains(t, configPaths, expectedConfigPath)
|
||||
})
|
||||
|
||||
t.Run("XDG_CONFIG_HOME is respected if set", func(t *testing.T) {
|
||||
t.Setenv(xdgConfigHome, "/foo/bar")
|
||||
|
||||
configPaths := getConfigPaths()
|
||||
assertContains(t, configPaths, filepath.Join("/", "foo", "bar", "autorestic"))
|
||||
})
|
||||
}
|
20
cmd/uninstall.go
Normal file
20
cmd/uninstall.go
Normal file
@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal/bins"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var uninstallCmd = &cobra.Command{
|
||||
Use: "uninstall",
|
||||
Short: "Uninstall restic and autorestic",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
restic, _ := cmd.Flags().GetBool("restic")
|
||||
bins.Uninstall(restic)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(uninstallCmd)
|
||||
uninstallCmd.Flags().Bool("restic", false, "also uninstall restic.")
|
||||
}
|
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
|
||||
}
|
21
cmd/upgrade.go
Normal file
21
cmd/upgrade.go
Normal file
@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/cupcakearmy/autorestic/internal/bins"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var upgradeCmd = &cobra.Command{
|
||||
Use: "upgrade",
|
||||
Short: "Upgrade autorestic and restic",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
restic, _ := cmd.Flags().GetBool("restic")
|
||||
err := bins.Upgrade(restic)
|
||||
CheckErr(err)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(upgradeCmd)
|
||||
upgradeCmd.Flags().Bool("restic", true, "also update restic")
|
||||
}
|
2
docs/.gitignore
vendored
Normal file
2
docs/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
.next
|
1
docs/.nvmrc
Normal file
1
docs/.nvmrc
Normal file
@ -0,0 +1 @@
|
||||
v22.7.0
|
38
docs/_toc.md
38
docs/_toc.md
@ -1,38 +0,0 @@
|
||||
[Home](/)
|
||||
[Quick Start](/quick)
|
||||
[Installation](/installation)
|
||||
[Configuration](/config)
|
||||
|
||||
> :Collapse label=Locations
|
||||
>
|
||||
> [Overview](/location/overview)
|
||||
> [Hooks](/location/hooks)
|
||||
> [Excluding Files](/location/exclude)
|
||||
> [Forget Policy](/location/forget)
|
||||
> [Cron](/location/cron)
|
||||
> [Docker Volumes](/location/docker)
|
||||
|
||||
> :Collapse label=Backend
|
||||
>
|
||||
> [Overview](/backend/overview)
|
||||
> [Available Backends](/backend/available)
|
||||
|
||||
> :Collapse label=CLI
|
||||
>
|
||||
> [General](/cli/general)
|
||||
> [Info](/cli/info)
|
||||
> [Check](/cli/check)
|
||||
> [Backup](/cli/backup)
|
||||
> [Restore](/cli/restore)
|
||||
> [Forget](/cli/forget)
|
||||
> [Cron](/cli/cron)
|
||||
> [Exec](/cli/exec)
|
||||
> [Install](/cli/install)
|
||||
> [Uninstall](/cli/uninstall)
|
||||
> [Update](/cli/update)
|
||||
|
||||
[Examples](/examples)
|
||||
|
||||
[QA](/qa)
|
||||
|
||||
[Contributors](/contrib)
|
@ -1,16 +0,0 @@
|
||||
# 💽 Backends
|
||||
|
||||
Backends are the ouputs of the backup process. Each location needs at least one.
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
backends:
|
||||
name-of-backend:
|
||||
type: local
|
||||
path: /data/my/backups
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
We restic supports multiple types of backends. See the [full list](/backend/available) for details.
|
||||
|
||||
> :ToCPrevNext
|
@ -1,13 +0,0 @@
|
||||
# Backup
|
||||
|
||||
```bash
|
||||
autorestic backup [-l, --location] [-a, --all]
|
||||
```
|
||||
|
||||
Performs a backup of all locations if the `-a` flag is passed. To only backup some locations pass one or more `-l` or `--location` flags.
|
||||
|
||||
```bash
|
||||
autorestic backup -l my-location
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -1,15 +0,0 @@
|
||||
# Check
|
||||
|
||||
```bash
|
||||
autorestic check [-b, --backend] [-a, --all]
|
||||
```
|
||||
|
||||
Cheks if one or more backend are configured properly and initializes them if they are not already.
|
||||
|
||||
This is mostly an internal command, but useful to verify if a backend is configured correctly.
|
||||
|
||||
```bash
|
||||
autorestic check -b my-backend
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -1,11 +0,0 @@
|
||||
# Cron
|
||||
|
||||
```bash
|
||||
autorestic cron
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
> :ToCPrevNext
|
@ -1,15 +0,0 @@
|
||||
# Exec
|
||||
|
||||
```bash
|
||||
autorestic exec [-b, --backend] [-a, --all] <command> -- [native options]
|
||||
```
|
||||
|
||||
This is avery handy command which enables you to run any native restic command on desired backends. An example would be listing all the snapshots of all your backends:
|
||||
|
||||
```bash
|
||||
autorestic exec -a -- snapshots
|
||||
```
|
||||
|
||||
With `exec` you can basically run every cli command that you would be able to run with the restic cli. It only pre-fills path, key, etc.
|
||||
|
||||
> :ToCPrevNext
|
@ -1,11 +0,0 @@
|
||||
# Forget
|
||||
|
||||
```bash
|
||||
autorestic forget [-l, --location] [-a, --all] [--dry-run]
|
||||
```
|
||||
|
||||
This will prune and remove old data form the backends according to the [keep policy you have specified for the location](/locations/forget)
|
||||
|
||||
The `--dry-run` flag will do a dry run showing what would have been deleted, but won't touch the actual data.
|
||||
|
||||
> :ToCPrevNext
|
@ -1,29 +0,0 @@
|
||||
# General
|
||||
|
||||
## `--version`
|
||||
|
||||
Prints the current version
|
||||
|
||||
```bash
|
||||
autorestic --version
|
||||
```
|
||||
|
||||
## `--c, --config`
|
||||
|
||||
Specify the config file to be used.
|
||||
If omitted `autorestic` will search for for a `.autorestic.yml` in the current directory and your home directory.
|
||||
|
||||
```bash
|
||||
autorestic -c /path/to/my/config.yml
|
||||
```
|
||||
|
||||
## `--ci`
|
||||
|
||||
> Available since version 0.22
|
||||
|
||||
Run the CLI in CI Mode, which means there will be no interactivity.
|
||||
This can be useful when you want to run cron e.g. as all the output will be saved.
|
||||
|
||||
```bash
|
||||
autorestic --ci
|
||||
```
|
@ -1,17 +0,0 @@
|
||||
# Restore
|
||||
|
||||
```bash
|
||||
autorestic restore [-l, --location] [--from backend] [--to <out dir>]
|
||||
```
|
||||
|
||||
This will restore all the locations to the selected target. If for one location there are more than one backends specified autorestic will take the first one.
|
||||
|
||||
## Example
|
||||
|
||||
```bash
|
||||
autorestic restore -l home --from hdd --to /path/where/to/restore
|
||||
```
|
||||
|
||||
This will restore the location `home` to the `/path/where/to/restore` folder and taking the data from the backend `hdd`
|
||||
|
||||
> :ToCPrevNext
|
@ -1,9 +0,0 @@
|
||||
# Uninstall
|
||||
|
||||
Installs both restic and autorestic from `/usr/local/bin`.
|
||||
|
||||
```bash
|
||||
autorestic uninstall
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -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
|
@ -1,42 +0,0 @@
|
||||
# 🎛 Config File
|
||||
|
||||
## Path
|
||||
|
||||
By default autorestic searches for a `.autorestic.yml` file in the current directory and your home folder.
|
||||
|
||||
- `./.autorestic.yml`
|
||||
- `~/.autorestic.yml`
|
||||
|
||||
You can also specify a custom file with the `-c path/to/some/config.yml`
|
||||
|
||||
> **⚠️ WARNING ⚠️**
|
||||
>
|
||||
> Note that the data is automatically encrypted on the server. The key will be generated and added to your config file. Every backend will have a separate key. **You should keep a copy of the keys or config file somewhere in case your server dies**. Otherwise DATA IS LOST!
|
||||
|
||||
## Example configuration
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
home:
|
||||
from: /home/me
|
||||
to: remote
|
||||
|
||||
important:
|
||||
from: /path/to/important/stuff
|
||||
to:
|
||||
- remote
|
||||
- hdd
|
||||
|
||||
backends:
|
||||
remote:
|
||||
type: b2
|
||||
path: 'myBucket:backup/home'
|
||||
B2_ACCOUNT_ID: account_id
|
||||
B2_ACCOUNT_KEY: account_key
|
||||
|
||||
hdd:
|
||||
type: local
|
||||
path: /mnt/my_external_storage
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -1,8 +0,0 @@
|
||||
# 🙋♀️🙋♂️ Contributors
|
||||
|
||||
This amazing people helped the project!
|
||||
|
||||
- @ChanceM [Docs]
|
||||
- @EliotBerriot [Docs, Pruning, S3]
|
||||
|
||||
> :ToCPrevNext
|
@ -1,21 +0,0 @@
|
||||
# 🐣 Examples
|
||||
|
||||
## Exec
|
||||
|
||||
### List all the snapshots for all the backends
|
||||
|
||||
```bash
|
||||
autorestic exec -a -- snapshots
|
||||
```
|
||||
|
||||
### Unlock a locked repository
|
||||
|
||||
If you accidentally cancelled a running operation this could be useful.
|
||||
|
||||
Only do this if you know what you are doing.
|
||||
|
||||
```bash
|
||||
autorestic exec -b my-backend -- unlock
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -1,11 +0,0 @@
|
||||
# 🛳 Installation
|
||||
|
||||
Linux & macOS. Windows is not supported. If you have problems installing please open an issue :)
|
||||
|
||||
Autorestic requires `curl`, `wget` and `bzip2` to be installed. For most systems these should be already installed.
|
||||
|
||||
```bash
|
||||
curl -s https://raw.githubusercontent.com/CupCakeArmy/autorestic/master/install.sh | bash
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -1,49 +0,0 @@
|
||||
# Cron
|
||||
|
||||
Often it is usefull to trigger backups autmatically. For this we can specify a `cron` attribute to each location.
|
||||
|
||||
> Available since version 0.18
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to: my-backend
|
||||
cron: '0 3 * * 0' # Every Sunday at 3:00
|
||||
```
|
||||
|
||||
Here is a awesome website with [some examples](https://crontab.guru/examples.html) and an [explorer](https://crontab.guru/)
|
||||
|
||||
## Installing the cron
|
||||
|
||||
**This has to be done only once, regadless of now many cros you have in your config file.**
|
||||
|
||||
To actually enable cron jobs you need something to call `autorestic cron` on a timed shedule.
|
||||
Note that the shedule has nothing to do with the `cron` attribute in each location.
|
||||
My advise would be to trigger the command every 5min, but if you have a cronjob that runs only once a week, it's probably enough to shedule it once a day.
|
||||
|
||||
### Crontab
|
||||
|
||||
Here is an example using crontab, but systemd would do too.
|
||||
|
||||
First, open your crontab in edit mode
|
||||
|
||||
```bash
|
||||
crontab -e
|
||||
```
|
||||
|
||||
Then paste this at the bottom of the file and save it. Note that in this specific example the `.autorestic.yml` is located in `/srv/`. You need to modify that part of course to fit your config file.
|
||||
|
||||
```bash
|
||||
# This is required, as it otherwise cannot find restic as a command.
|
||||
PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
|
||||
# Example running every 5 minutes
|
||||
*/5 * * * * autorestic -c /srv/.autorestic.yml --ci cron
|
||||
```
|
||||
|
||||
> The `--ci` option is not required, but recommended
|
||||
|
||||
Now you can add as many `cron` attributes as you wish in the config file ⏱
|
||||
|
||||
> :ToCPrevNext
|
@ -1,58 +0,0 @@
|
||||
# Docker
|
||||
|
||||
autorestic supports docker volumes directly, without needing them to be mounted to the host filesystem.
|
||||
|
||||
> Available since version 0.13
|
||||
|
||||
Let see an example.
|
||||
|
||||
```yaml | docker-compose.yml
|
||||
version: '3.7'
|
||||
|
||||
volumes:
|
||||
data:
|
||||
name: my-data
|
||||
|
||||
services:
|
||||
api:
|
||||
image: alpine
|
||||
volumes:
|
||||
- data:/foo/bar
|
||||
```
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
hello:
|
||||
from: 'volume:my-data'
|
||||
to:
|
||||
- remote
|
||||
options:
|
||||
forget:
|
||||
keep-last: 14 # Useful for limitations explained belowd
|
||||
|
||||
backends:
|
||||
remote: ...
|
||||
```
|
||||
|
||||
Now you can backup and restore as always.
|
||||
|
||||
```bash
|
||||
autorestic -l hello backup
|
||||
```
|
||||
|
||||
```bash
|
||||
autorestic -l hello restore
|
||||
```
|
||||
|
||||
If the volume does not exist on restore, autorestic will create it for you and then fill it with the data.
|
||||
|
||||
## Limitations
|
||||
|
||||
Unfortunately there are some limitations when backing up directly from a docker volume without mounting the volume to the host:
|
||||
|
||||
1. Incremental updates are not possible right now due to how the current docker mounting works. This means that it will take significantely more space.
|
||||
2. Exclude patterns and files also do not work as restic only sees a compressed tarball as source and not the actual data.
|
||||
|
||||
If you are curious or have ideas how to improve this, please [read more here](https://github.com/cupcakearmy/autorestic/issues/4#issuecomment-568771951). Any help is welcomed 🙂
|
||||
|
||||
> :ToCPrevNext
|
@ -1,25 +0,0 @@
|
||||
# Forget/Prune Policies
|
||||
|
||||
Autorestic supports declaring snapshot policies for location to avoid keeping old snapshot around if you don't need them.
|
||||
|
||||
This is based on [Restic's snapshots policies](https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy), and can be enabled for each location as shown below:
|
||||
|
||||
> **Note** This is a full example, of course you also can specify only one of them
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
etc:
|
||||
from: /etc
|
||||
to: local
|
||||
options:
|
||||
forget:
|
||||
keep-last: 5 # always keep at least 5 snapshots
|
||||
keep-hourly: 3 # keep 3 last hourly shapshots
|
||||
keep-daily: 4 # keep 4 last daily shapshots
|
||||
keep-weekly: 1 # keep 1 last weekly shapshots
|
||||
keep-monthly: 12 # keep 12 last monthly shapshots
|
||||
keep-yearly: 7 # keep 7 last yearly shapshots
|
||||
keep-within: '2w' # keep snapshots from the last 2 weeks
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -1,18 +0,0 @@
|
||||
# Hooks
|
||||
|
||||
Sometimes you might want to stop an app/db before backing up data and start the service again after the backup has completed. This is what the hooks are made for. Simply add them to your location config. You can have as many commands as you wish.
|
||||
|
||||
```yml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to: my-backend
|
||||
hooks:
|
||||
before:
|
||||
- echo "Hello"
|
||||
- echo "Human"
|
||||
after:
|
||||
- echo "kthxbye"
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
6
docs/next.config.js
Normal file
6
docs/next.config.js
Normal file
@ -0,0 +1,6 @@
|
||||
const withNextra = require('nextra')({
|
||||
theme: 'nextra-theme-docs',
|
||||
themeConfig: './theme.config.jsx',
|
||||
})
|
||||
|
||||
module.exports = withNextra()
|
15
docs/package.json
Normal file
15
docs/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"scripts": {
|
||||
"build": "NEXT_TELEMETRY_DISABLED=1 next build",
|
||||
"dev": "NEXT_TELEMETRY_DISABLED=1 next",
|
||||
"start": "NEXT_TELEMETRY_DISABLED=1 next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^14.2.7",
|
||||
"nextra": "^2.13.4",
|
||||
"nextra-theme-docs": "^2.13.4",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"packageManager": "pnpm@9.9.0"
|
||||
}
|
10
docs/pages/_meta.json
Normal file
10
docs/pages/_meta.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"index": "Home",
|
||||
"quick": "Quick Start",
|
||||
"installation": "Installation",
|
||||
"config": "Configuration",
|
||||
"location": "Locations",
|
||||
"backend": "Backend",
|
||||
"cli": "CLI",
|
||||
"migration": "Migration"
|
||||
}
|
6
docs/pages/backend/_meta.json
Normal file
6
docs/pages/backend/_meta.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"index": "Overview",
|
||||
"available": "Available backends",
|
||||
"options": "Options",
|
||||
"env": "Environment"
|
||||
}
|
@ -4,6 +4,8 @@ In theory [all the restic backends](https://restic.readthedocs.io/en/stable/030_
|
||||
|
||||
Those tested are the following:
|
||||
|
||||
> ℹ️ You can also [specify the `env` variables in a config file](/backend/env) to separate them from the config file.
|
||||
|
||||
## Local
|
||||
|
||||
```yaml
|
||||
@ -19,11 +21,18 @@ backends:
|
||||
backends:
|
||||
name-of-backend:
|
||||
type: b2
|
||||
path: 'myAccount:myBucket/my/path'
|
||||
B2_ACCOUNT_ID: backblaze_account_id
|
||||
B2_ACCOUNT_KEY: backblaze_account_key
|
||||
path: 'bucket_name'
|
||||
# Or With a path
|
||||
# path: 'bucket_name:/some/path'
|
||||
env:
|
||||
B2_ACCOUNT_ID: 'backblaze_keyID'
|
||||
B2_ACCOUNT_KEY: 'backblaze_applicationKey'
|
||||
```
|
||||
|
||||
#### API Keys gotcha
|
||||
|
||||
If you use a _File name prefix_ when making the application key, do not include a leading slash. Make sure to include this prefix in the path (e.g. `path: 'bucket_name:my/path'`).
|
||||
|
||||
## S3 / Minio
|
||||
|
||||
```yaml
|
||||
@ -33,8 +42,9 @@ backends:
|
||||
path: s3.amazonaws.com/bucket_name
|
||||
# Minio
|
||||
# path: http://localhost:9000/bucket_name
|
||||
AWS_ACCESS_KEY_ID: my_key
|
||||
AWS_SECRET_ACCESS_KEY: my_secret
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: my_key
|
||||
AWS_SECRET_ACCESS_KEY: my_secret
|
||||
```
|
||||
|
||||
## SFTP
|
||||
@ -57,6 +67,19 @@ backends:
|
||||
name-of-backend:
|
||||
type: rest
|
||||
path: http://localhost:8000/repo_name
|
||||
# Or authenticated
|
||||
path: https://user:pass@host:6969/path
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
||||
Optionally you can set user and password separately
|
||||
|
||||
```yaml
|
||||
backends:
|
||||
rest:
|
||||
type: rest
|
||||
path: http://localhost:6969/path
|
||||
key: ...
|
||||
rest:
|
||||
user: user
|
||||
password: pass
|
||||
```
|
65
docs/pages/backend/env.md
Normal file
65
docs/pages/backend/env.md
Normal file
@ -0,0 +1,65 @@
|
||||
# Environment
|
||||
|
||||
> ⚠ Available since version `v1.4.0`
|
||||
|
||||
Sometimes it's favorable not having the encryption keys in the config files.
|
||||
For that `autorestic` allows passing the env variables to backend password as `ENV` variables, or through an env file.
|
||||
You can also pass whatever `env` variable to restic by prefixing it with `AUTORESTIC_[BACKEND NAME]_`.
|
||||
|
||||
> ℹ️ Env variables and file overwrite the config file in the following order:
|
||||
>
|
||||
> Env Variables > Env File (`.autorestic.env`) > Config file (`.autorestic.yaml`)
|
||||
|
||||
## Env file
|
||||
|
||||
Alternatively `autorestic` can load an env file, located next to `.autorestic.yml` called `.autorestic.env`.
|
||||
|
||||
```
|
||||
AUTORESTIC_FOO_RESTIC_PASSWORD=secret123
|
||||
```
|
||||
|
||||
### Example with repository password
|
||||
|
||||
The syntax for the `ENV` variables is as follows: `AUTORESTIC_[BACKEND NAME]_RESTIC_PASSWORD`.
|
||||
|
||||
```yaml | autorestic.yaml
|
||||
backend:
|
||||
foo:
|
||||
type: ...
|
||||
path: ...
|
||||
key: secret123 # => AUTORESTIC_FOO_RESTIC_PASSWORD=secret123
|
||||
```
|
||||
|
||||
This means we could remove `key: secret123` from `.autorestic.yaml` and execute as follows:
|
||||
|
||||
```bash
|
||||
AUTORESTIC_FOO_RESTIC_PASSWORD=secret123 autorestic backup ...
|
||||
```
|
||||
|
||||
### Example with Backblaze B2
|
||||
|
||||
```yaml | autorestic.yaml
|
||||
backends:
|
||||
bb:
|
||||
type: b2
|
||||
path: myBucket
|
||||
key: myPassword
|
||||
env:
|
||||
B2_ACCOUNT_ID: 123
|
||||
B2_ACCOUNT_KEY: 456
|
||||
```
|
||||
|
||||
You could create an `.autorestic.env` or pass the following `ENV` variables to autorestic:
|
||||
|
||||
```
|
||||
AUTORESTIC_BB_RESTIC_PASSWORD=myPassword
|
||||
AUTORESTIC_BB_B2_ACCOUNT_ID=123
|
||||
AUTORESTIC_BB_B2_ACCOUNT_KEY=456
|
||||
```
|
||||
|
||||
```yaml | autorestic.yaml
|
||||
backends:
|
||||
bb:
|
||||
type: b2
|
||||
path: myBucket
|
||||
```
|
40
docs/pages/backend/index.md
Normal file
40
docs/pages/backend/index.md
Normal file
@ -0,0 +1,40 @@
|
||||
# 💽 Backends
|
||||
|
||||
Backends are the outputs of the backup process. Each location needs at least one.
|
||||
|
||||
Note: names of backends MUST be lower case!
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
backends:
|
||||
name-of-backend:
|
||||
type: local
|
||||
path: /data/my/backups
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
We restic supports multiple types of backends. See the [full list](/backend/available) for details.
|
||||
|
||||
## Avoid Generating Keys
|
||||
|
||||
By default, `autorestic` will generate a key for every backend if none is defined. This is done by updating your config file with the key.
|
||||
|
||||
In cases where you want to provide the key yourself, you can ensure that `autorestic` doesn't accidentally generate one for you by setting `requireKey: true`.
|
||||
|
||||
Example:
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
backends:
|
||||
foo:
|
||||
type: local
|
||||
path: /data/my/backups
|
||||
# Alternatively, you can set the key through the `AUTORESTIC_FOO_RESTIC_PASSWORD` environment variable.
|
||||
key: ... your key here ...
|
||||
requireKey: true
|
||||
```
|
||||
|
||||
With this setting, if a key is missing, `autorestic` will crash instead of generating a new key and updating your config file.
|
17
docs/pages/backend/options.md
Normal file
17
docs/pages/backend/options.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Options
|
||||
|
||||
> ℹ️ For more detail see the [location docs](/location/options) for options, as they are the same.
|
||||
|
||||
```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.
|
3
docs/pages/cli/_meta.json
Normal file
3
docs/pages/cli/_meta.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"general": "General"
|
||||
}
|
26
docs/pages/cli/backup.md
Normal file
26
docs/pages/cli/backup.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Backup
|
||||
|
||||
```bash
|
||||
autorestic backup [-l, --location] [-a, --all] [--dry-run]
|
||||
```
|
||||
|
||||
Performs a backup of all locations if the `-a` flag is passed. To only backup some locations pass one or more `-l` or `--location` flags.
|
||||
|
||||
The `--dry-run` flag will do a dry run showing what would have been deleted, but won't touch the actual data.
|
||||
|
||||
|
||||
```bash
|
||||
# All
|
||||
autorestic backup -a
|
||||
|
||||
# Some
|
||||
autorestic backup -l foo -l bar
|
||||
```
|
||||
|
||||
## Specific location
|
||||
|
||||
`autorestic` also allows selecting specific backends for a location with the `location@backend` syntax.
|
||||
|
||||
```bash
|
||||
autorestic backup -l location@backend
|
||||
```
|
9
docs/pages/cli/check.md
Normal file
9
docs/pages/cli/check.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Check
|
||||
|
||||
```bash
|
||||
autorestic check
|
||||
```
|
||||
|
||||
Checks locations and backends are configured properly and initializes them if they are not already.
|
||||
|
||||
This is mostly an internal command, but useful to verify if a backend is configured correctly.
|
15
docs/pages/cli/completion.md
Normal file
15
docs/pages/cli/completion.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Completion
|
||||
|
||||
```bash
|
||||
autorestic completion [bash|zsh|fish|powershell]
|
||||
```
|
||||
|
||||
Autorestic can generate shell completions automatically to make the experience even easier.
|
||||
Supported shells are
|
||||
|
||||
- bash
|
||||
- zsh
|
||||
- fish
|
||||
- powershell
|
||||
|
||||
To see how to install run `autorestic help completion` and follow the instructions for your specific shell
|
11
docs/pages/cli/cron.md
Normal file
11
docs/pages/cli/cron.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Cron
|
||||
|
||||
```bash
|
||||
autorestic cron [--lean]
|
||||
```
|
||||
|
||||
This command is mostly intended to be triggered by an automated system like systemd or crontab.
|
||||
|
||||
It will run cron jobs as [specified in the cron section](/location/cron) of a specific location.
|
||||
|
||||
The `--lean` flag will omit output like _skipping location x: not due yet_. This can be useful if you are dumping the output of the cron job to a log file and don't want to be overwhelmed by the output log.
|
13
docs/pages/cli/exec.md
Normal file
13
docs/pages/cli/exec.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Exec
|
||||
|
||||
```bash
|
||||
autorestic exec [-b, --backend] [-a, --all] <command> -- [native options]
|
||||
```
|
||||
|
||||
This is a very handy command which enables you to run any native restic command on desired backends. Generally you will want to include the verbose flag `-v, --verbose` to see the output. An example would be listing all the snapshots of all your backends:
|
||||
|
||||
```bash
|
||||
autorestic exec -av -- snapshots
|
||||
```
|
||||
|
||||
With `exec` you can basically run every cli command that you would be able to run with the restic cli. It only pre-fills path, key, etc.
|
11
docs/pages/cli/forget.md
Normal file
11
docs/pages/cli/forget.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Forget
|
||||
|
||||
```bash
|
||||
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/options/forget).
|
||||
|
||||
The `--dry-run` flag will do a dry run showing what would have been deleted, but won't touch the actual data.
|
||||
|
||||
The `--prune` flag will also [prune the data](https://restic.readthedocs.io/en/latest/060_forget.html#removing-backup-snapshots). This is a costly operation that can take longer, however it will free up the actual space.
|
36
docs/pages/cli/general.md
Normal file
36
docs/pages/cli/general.md
Normal file
@ -0,0 +1,36 @@
|
||||
# General
|
||||
|
||||
## `-c, --config`
|
||||
|
||||
Specify the config file to be used (must use .yml as an extension).
|
||||
If omitted `autorestic` will search for for a `.autorestic.yml` in the current directory and your home directory.
|
||||
|
||||
```bash
|
||||
autorestic -c /path/to/my/config.yml
|
||||
```
|
||||
|
||||
## `--ci`
|
||||
|
||||
Run the CLI in CI Mode, which means there will be no interactivity, no colors and automatically sets the `--verbose` flag.
|
||||
|
||||
This can be useful when you want to run cron e.g. as all the output will be saved.
|
||||
|
||||
```bash
|
||||
autorestic --ci backup -a
|
||||
```
|
||||
|
||||
## `-v, --verbose`
|
||||
|
||||
Verbose mode will show the output of the native restic commands that are otherwise not printed out. Useful for debugging or logging in automated tasks.
|
||||
|
||||
```bash
|
||||
autorestic --verbose backup -a
|
||||
```
|
||||
|
||||
## `--restic-bin`
|
||||
|
||||
With `--restic-bin` you can specify to run a specific restic binary. This can be useful if you want to [create a custom binary with root access that can be executed by any user](https://restic.readthedocs.io/en/stable/080_examples.html#full-backup-without-root).
|
||||
|
||||
```bash
|
||||
autorestic --restic-bin /some/path/to/my/custom/restic/binary
|
||||
```
|
@ -14,5 +14,3 @@ autorestic info
|
||||
```bash
|
||||
autorestic -c path/to/some/config.yml info
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
@ -5,5 +5,3 @@ Installs both restic and autorestic to `/usr/local/bin`.
|
||||
```bash
|
||||
autorestic install
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
17
docs/pages/cli/restore.md
Normal file
17
docs/pages/cli/restore.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Restore
|
||||
|
||||
```bash
|
||||
autorestic restore [-l, --location] [--from backend] [--to <out dir>] [-f, --force] [snapshot]
|
||||
```
|
||||
|
||||
This will restore the location to the selected target. If for one location there are more than one backends specified autorestic will take the first one. If no specific snapshot is specified `autorestic` will use `latest`.
|
||||
|
||||
If you are sure you can pass the `-f, --force` flag and the data will be overwritten in the destination. However note that this will overwrite all the data existent in the backup, not only the 1 file that is missing e.g.
|
||||
|
||||
## Example
|
||||
|
||||
```bash
|
||||
autorestic restore -l home --from hdd --to /path/where/to/restore
|
||||
```
|
||||
|
||||
This will restore the location `home` to the `/path/where/to/restore` folder and taking the data from the backend `hdd`
|
7
docs/pages/cli/uninstall.md
Normal file
7
docs/pages/cli/uninstall.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Uninstall
|
||||
|
||||
Uninstalls both restic and autorestic from `/usr/local/bin`.
|
||||
|
||||
```bash
|
||||
autorestic uninstall
|
||||
```
|
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
|
||||
```
|
9
docs/pages/cli/upgrade.md
Normal file
9
docs/pages/cli/upgrade.md
Normal file
@ -0,0 +1,9 @@
|
||||
# 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.
|
17
docs/pages/community.md
Normal file
17
docs/pages/community.md
Normal file
@ -0,0 +1,17 @@
|
||||
# 🏘 Community
|
||||
|
||||
## Software
|
||||
|
||||
A list of community driven projects. (No official affiliation)
|
||||
|
||||
- SystemD Units: <https://gitlab.com/py_crash/autorestic-systemd-units>
|
||||
- Docker image: <https://github.com/pascaliske/docker-autorestic>
|
||||
- Ansible Role: <https://github.com/adsanz/ansible-restic-role>
|
||||
- Ansible Role: <https://github.com/ItsNotGoodName/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://github.com/dbrennand/ansible-role-autorestic>
|
||||
|
||||
## Writing
|
||||
|
||||
- [restic: excellent resource for local and cloud backup](https://notes.nicfab.eu/en/posts/restic/)
|
88
docs/pages/config.md
Normal file
88
docs/pages/config.md
Normal file
@ -0,0 +1,88 @@
|
||||
# 🎛 Config File
|
||||
|
||||
## Path
|
||||
|
||||
By default autorestic searches for a `.autorestic.yml` file in the current directory, your home folder and your XDG config folder (`~/.config/` by default):
|
||||
|
||||
- `./.autorestic.yml`
|
||||
- `~/.autorestic.yml`
|
||||
- `~/.config/autorestic/.autorestic.yml`
|
||||
|
||||
You can also specify a custom file with the `-c path/to/some/config.yml`
|
||||
|
||||
> **⚠️ WARNING ⚠️**
|
||||
>
|
||||
> Note that the data is automatically encrypted on the server. The key will be generated and added to your config file. Every backend will have a separate key. **You should keep a copy of the keys or config file somewhere in case your server dies**. Otherwise DATA IS LOST!
|
||||
|
||||
## Example configuration
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
locations:
|
||||
home:
|
||||
from: /home/me
|
||||
to: remote
|
||||
|
||||
important:
|
||||
from: /path/to/important/stuff
|
||||
to:
|
||||
- remote
|
||||
- hdd
|
||||
|
||||
backends:
|
||||
remote:
|
||||
type: b2
|
||||
path: 'myBucket:backup/home'
|
||||
env:
|
||||
B2_ACCOUNT_ID: account_id
|
||||
B2_ACCOUNT_KEY: account_key
|
||||
|
||||
hdd:
|
||||
type: local
|
||||
path: /mnt/my_external_storage
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
A handy tool for more advanced configurations is to use yaml aliases.
|
||||
These must be specified under the global `extras` key in the `.autorestic.yml` config file.
|
||||
Aliases allow to reuse snippets of config throughout the same file.
|
||||
|
||||
The following example shows how the locations `a` and `b` share the same hooks and forget policies.
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
extras:
|
||||
hooks: &foo
|
||||
prevalidate:
|
||||
- echo "Wake up!"
|
||||
before:
|
||||
- echo "Hello"
|
||||
after:
|
||||
- echo "kthxbye"
|
||||
policies: &bar
|
||||
keep-daily: 14
|
||||
keep-weekly: 52
|
||||
|
||||
backends:
|
||||
# ...
|
||||
locations:
|
||||
a:
|
||||
from: /data/a
|
||||
to: some
|
||||
hooks:
|
||||
<<: *foo
|
||||
options:
|
||||
forget:
|
||||
<<: *bar
|
||||
b:
|
||||
from: data/b
|
||||
to: some
|
||||
hooks:
|
||||
<<: *foo
|
||||
options:
|
||||
forget:
|
||||
<<: *bar
|
||||
```
|
19
docs/pages/contributors.md
Normal file
19
docs/pages/contributors.md
Normal file
@ -0,0 +1,19 @@
|
||||
# 🙋♀️🙋♂️ Contributors
|
||||
|
||||
This amazing people helped the project!
|
||||
|
||||
- @agateblue - Docs, Pruning, S3.
|
||||
- @g-a-c - Update/Install bugs.
|
||||
- @jjromannet - Bug fixes.
|
||||
- @fariszr - Docker image improvements.
|
||||
- @david-boles - Docs.
|
||||
- @SebDanielsson - Brew.
|
||||
- @n194 - AUR Package.
|
||||
- @olofvndrhr - Healthchecks example.
|
||||
- @jin-park-dev - Typos.
|
||||
- @sumnerboy12 - Typos.
|
||||
- @FuzzyMistborn - Typos.
|
||||
- @ChanceM - Typos.
|
||||
- @TheForcer - Typos.
|
||||
- @themorlan - Typos.
|
||||
- @somebox - Typos.
|
28
docs/pages/docker.md
Normal file
28
docs/pages/docker.md
Normal 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 -c /data/.autorestic.yaml
|
||||
```
|
||||
|
||||
## 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 \\
|
||||
...
|
||||
```
|
38
docs/pages/examples.md
Normal file
38
docs/pages/examples.md
Normal file
@ -0,0 +1,38 @@
|
||||
# 🐣 Examples
|
||||
|
||||
## List all the snapshots for all the backends
|
||||
|
||||
```bash
|
||||
autorestic exec -av -- snapshots
|
||||
```
|
||||
|
||||
## Unlock a locked repository
|
||||
|
||||
This can come in handy if a backup process crashed or if it was accidentally cancelled. Then the repository would still be locked without an actual process using it. Only do this if you know what you are doing and are sure no other process is actually reading/writing to the repository of course.
|
||||
|
||||
```bash
|
||||
autorestic exec -b my-backend -- unlock
|
||||
```
|
||||
|
||||
## Use hooks to integrate with [healthchecks](https://healthchecks.io/)
|
||||
|
||||
> Thanks to @olofvndrhr for providing it ❤️
|
||||
|
||||
```yaml
|
||||
extras:
|
||||
healthchecks: &healthchecks
|
||||
hooks:
|
||||
before:
|
||||
- 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Starting backup for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>/start'
|
||||
failure:
|
||||
- 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Backup failed for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>/fail'
|
||||
success:
|
||||
- 'curl -m 10 --retry 5 -X POST -H "Content-Type: text/plain" --data "Backup successful for location: ${AUTORESTIC_LOCATION}" https://<healthchecks-url>/ping/<uid>'
|
||||
|
||||
locations:
|
||||
something:
|
||||
<<: *healthchecks
|
||||
from: /somewhere
|
||||
to:
|
||||
- somewhere-else
|
||||
```
|
@ -1,16 +1,10 @@
|
||||
# `autorestic`
|
||||
# autorestic
|
||||
|
||||
High backup level CLI utility for [restic](https://restic.net/).
|
||||
|
||||
Autorestic is a wrapper around the amazing [restic](https://restic.net/). While being amazing the restic cli can be a bit overwhelming and difficult to manage if you have many different location that you want to backup to multiple locations. This utility is aimed at making this easier 🙂
|
||||
|
||||
<!--  -->
|
||||
|
||||
## ✈️ Roadmap
|
||||
|
||||
~~I would like to make the official `1.0` release in the coming months. Until then please feel free to file issues or feature requests so that the tool is as flexible as possible :)~~
|
||||
|
||||
As of version `0.18` crons are supported wich where the last feature missing for a `1.0`. Will test this for a few weeks and then it's time for the first "real" release! 🎉 Also we now have waaay better docs 📒
|
||||
> If you are coming from `0.x` see the [upgrade guide](/upgrade).
|
||||
|
||||
## 🌈 Features
|
||||
|
||||
@ -19,9 +13,8 @@ As of version `0.18` crons are supported wich where the last feature missing for
|
||||
- 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
|
||||
|
||||
> :ToCPrevNext
|
||||
- Generated completions for `[bash|zsh|fish|powershell]`
|
33
docs/pages/installation.md
Normal file
33
docs/pages/installation.md
Normal file
@ -0,0 +1,33 @@
|
||||
# 🛳 Installation
|
||||
|
||||
Linux & macOS. Windows is not supported. If you have problems installing please open an issue :)
|
||||
|
||||
Autorestic requires `bash`, `wget` and `bzip2` to be installed. For most systems these should be already installed.
|
||||
|
||||
```bash
|
||||
wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash
|
||||
```
|
||||
|
||||
## Alternatives
|
||||
|
||||
### Docker
|
||||
|
||||
There is an official docker image over at [cupcakearmy/autorestic](https://hub.docker.com/r/cupcakearmy/autorestic).
|
||||
|
||||
For some examples see [here](/docker).
|
||||
|
||||
### 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.
|
||||
|
||||
### Brew
|
||||
|
||||
If you are on macOS you can install through brew: `brew install autorestic`.
|
||||
|
||||
### Fedora
|
||||
|
||||
Fedora users can install the [autorestic](https://src.fedoraproject.org/rpms/autorestic/) package with `dnf install autorestic`.
|
||||
|
||||
### AUR
|
||||
|
||||
If you are on Arch there is an [AUR Package](https://aur.archlinux.org/packages/autorestic-bin/)
|
7
docs/pages/location/_meta.json
Normal file
7
docs/pages/location/_meta.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"index": "Overview",
|
||||
"hooks": "Hooks",
|
||||
"options": "Options",
|
||||
"cron": "Cronjobs",
|
||||
"docker": "Docker volumes"
|
||||
}
|
53
docs/pages/location/cron.md
Normal file
53
docs/pages/location/cron.md
Normal file
@ -0,0 +1,53 @@
|
||||
# Cron
|
||||
|
||||
Often it is useful to trigger backups automatically. For this, we can specify a `cron` attribute to each location.
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to: my-backend
|
||||
cron: '0 3 * * 0' # Every Sunday at 3:00
|
||||
```
|
||||
|
||||
Here is an awesome website with [some examples](https://crontab.guru/examples.html) and an [explorer](https://crontab.guru/).
|
||||
|
||||
## Installing the cron
|
||||
|
||||
**This has to be done only once, regardless of how many cron jobs you have in your config file.**
|
||||
|
||||
To actually enable cron jobs you need something to call `autorestic cron` on a timed schedule.
|
||||
Note that the schedule has nothing to do with the `cron` attribute in each location.
|
||||
My advice would be to trigger the command every 5min, but if you have a cronjob that runs only once a week, it's probably enough to schedule it once a day.
|
||||
|
||||
### Crontab
|
||||
|
||||
Here is an example using crontab, but systemd would do too.
|
||||
|
||||
First, open your crontab in edit mode
|
||||
|
||||
```bash
|
||||
crontab -e
|
||||
```
|
||||
|
||||
Then paste this at the bottom of the file and save it. Note that in this specific example the config file is located at one of the default locations (e.g. `~/.autorestic.yml`). If your config is somewhere else you'll need to specify it using the `-c` option.
|
||||
|
||||
```bash
|
||||
# This is required, as it otherwise cannot find restic as a command.
|
||||
PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
|
||||
# Example running every 5 minutes
|
||||
*/5 * * * * autorestic -c /path/to/my/.autorestic.yml --ci cron
|
||||
```
|
||||
|
||||
> The `--ci` option is not required, but recommended
|
||||
|
||||
To debug a cron job you can use
|
||||
|
||||
```bash
|
||||
*/5 * * * * autorestic -c /path/to/my/.autorestic.yml --ci cron > /tmp/autorestic.log 2>&1
|
||||
```
|
||||
|
||||
Now you can add as many `cron` attributes as you wish in the config file ⏱
|
||||
|
||||
> Also note that manually triggered backups with `autorestic backup` will not influence the cron timeline, they are intentionally not linked.
|
37
docs/pages/location/docker.md
Normal file
37
docs/pages/location/docker.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Docker
|
||||
|
||||
autorestic supports docker volumes directly, without needing them to be mounted to the host filesystem.
|
||||
|
||||
```yaml | docker-compose.yml
|
||||
version: '3.8'
|
||||
|
||||
volumes:
|
||||
data:
|
||||
name: my-data
|
||||
|
||||
services:
|
||||
api:
|
||||
image: alpine
|
||||
volumes:
|
||||
- data:/foo/bar
|
||||
```
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
hello:
|
||||
from: my-data
|
||||
type: volume
|
||||
# ...
|
||||
```
|
||||
|
||||
Now you can backup and restore as always.
|
||||
|
||||
```bash
|
||||
autorestic backup -l hello
|
||||
```
|
||||
|
||||
```bash
|
||||
autorestic restore -l hello
|
||||
```
|
||||
|
||||
The volume has to exists whenever backing up or restoring.
|
85
docs/pages/location/hooks.md
Normal file
85
docs/pages/location/hooks.md
Normal file
@ -0,0 +1,85 @@
|
||||
# Hooks
|
||||
|
||||
If you want to perform some commands before and/or after a backup, you can use hooks.
|
||||
|
||||
They consist of a list of commands that will be executed in the same directory as the target `from`.
|
||||
|
||||
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 "Bye"
|
||||
failure:
|
||||
- echo "Something went wrong"
|
||||
success:
|
||||
- echo "Well done!"
|
||||
```
|
||||
|
||||
## Flowchart
|
||||
|
||||
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 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
|
||||
|
||||
All hooks are exposed to the `AUTORESTIC_LOCATION` environment variable, which contains the location name.
|
||||
|
||||
The `after` and `success` hooks have access to additional information with the following syntax:
|
||||
|
||||
```bash
|
||||
AUTORESTIC_[TYPE]_[I]
|
||||
AUTORESTIC_[TYPE]_[BACKEND_NAME]
|
||||
```
|
||||
|
||||
Every type of metadata is appended with both the name of the backend associated with and the number in which the backends where executed.
|
||||
|
||||
### Available Metadata Types
|
||||
|
||||
- `SNAPSHOT_ID`
|
||||
- `PARENT_SNAPSHOT_ID`
|
||||
- `FILES_ADDED`
|
||||
- `FILES_CHANGED`
|
||||
- `FILES_UNMODIFIED`
|
||||
- `DIRS_ADDED`
|
||||
- `DIRS_CHANGED`
|
||||
- `DIRS_UNMODIFIED`
|
||||
- `ADDED_SIZE`
|
||||
- `PROCESSED_FILES`
|
||||
- `PROCESSED_SIZE`
|
||||
- `PROCESSED_DURATION`
|
||||
|
||||
#### Example
|
||||
|
||||
Assuming you have a location `bar` that backs up to a single backend named `foo` you could expect the following env variables:
|
||||
|
||||
```bash
|
||||
AUTORESTIC_LOCATION=bar
|
||||
AUTORESTIC_FILES_ADDED_0=42
|
||||
AUTORESTIC_FILES_ADDED_FOO=42
|
||||
```
|
@ -3,10 +3,18 @@
|
||||
Locations can be seen as the input to the backup process. Generally this is simply a folder.
|
||||
The paths can be relative from the config file. A location can have multiple backends, so that the data is secured across multiple servers.
|
||||
|
||||
Note: names of locations MUST be lower case!
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
locations:
|
||||
my-location-name:
|
||||
from: path/to/backup
|
||||
# Or multiple
|
||||
# from:
|
||||
# - /a
|
||||
# - /b
|
||||
to:
|
||||
- name-of-backend
|
||||
- also-backup-to-this-backend
|
||||
@ -14,7 +22,7 @@ locations:
|
||||
|
||||
## `from`
|
||||
|
||||
This is the source of the location.
|
||||
This is the source of the location. Can be an `array` for multiple sources.
|
||||
|
||||
#### How are paths resolved?
|
||||
|
||||
@ -22,6 +30,4 @@ Paths can be absolute or relative. If relative they are resolved relative to the
|
||||
|
||||
## `to`
|
||||
|
||||
This is einther a single backend or an array of backends. The backends have to be configured in the same config file.
|
||||
|
||||
> :ToCPrevNext
|
||||
This is either a single backend or an array of backends. The backends have to be configured in the same config file.
|
3
docs/pages/location/options/_meta.json
Normal file
3
docs/pages/location/options/_meta.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"index": "Overview"
|
||||
}
|
31
docs/pages/location/options/copy.md
Normal file
31
docs/pages/location/options/copy.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Copy
|
||||
|
||||
Instead of specifying multiple `to` backends for a given `location` you can also use the `copy` option. Instead of recalculating the backup multiple times, you can copy the freshly copied snapshot from one backend to the other, avoiding recomputation.
|
||||
|
||||
###### Example
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to:
|
||||
- a #Fast
|
||||
- b #Fast
|
||||
- c #Slow
|
||||
```
|
||||
|
||||
Becomes
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to:
|
||||
- a
|
||||
- b
|
||||
copy:
|
||||
a:
|
||||
- c
|
||||
```
|
||||
|
||||
Instead of backing up to each backend separately, you can choose that the snapshot created to `a` will be copied over to `c`, avoiding heavy computation on `c`.
|
@ -1,6 +1,6 @@
|
||||
# Excluding files
|
||||
|
||||
If you want to exclude certain files or folders it done easily by specifiyng the right flags in the location you desire to filter.
|
||||
If you want to exclude certain files or folders it done easily by specifying the right flags in the location you desire to filter.
|
||||
|
||||
The flags are taken straight from the [restic cli exclude rules](https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files) so you can use any flag used there.
|
||||
|
||||
@ -16,5 +16,3 @@ locations:
|
||||
- '*.abc'
|
||||
exclude-file: .gitignore
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
55
docs/pages/location/options/forget.md
Normal file
55
docs/pages/location/options/forget.md
Normal file
@ -0,0 +1,55 @@
|
||||
# Forget/Prune Policies
|
||||
|
||||
Autorestic supports declaring snapshot policies for location to avoid keeping old snapshot around if you don't need them.
|
||||
|
||||
This is based on [Restic's snapshots policies](https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy), and can be enabled for each location as shown below:
|
||||
|
||||
> **Note** This is a full example, of course you also can specify only one of them
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
locations:
|
||||
etc:
|
||||
from: /etc
|
||||
to: local
|
||||
options:
|
||||
forget:
|
||||
keep-last: 5 # always keep at least 5 snapshots
|
||||
keep-hourly: 3 # keep 3 last hourly snapshots
|
||||
keep-daily: 4 # keep 4 last daily snapshots
|
||||
keep-weekly: 1 # keep 1 last weekly snapshots
|
||||
keep-monthly: 12 # keep 12 last monthly snapshots
|
||||
keep-yearly: 7 # keep 7 last yearly snapshots
|
||||
keep-within: '14d' # keep snapshots from the last 14 days
|
||||
```
|
||||
|
||||
## Globally
|
||||
|
||||
You can specify global forget policies that would be applied to all locations:
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
global:
|
||||
forget:
|
||||
keep-daily: 30
|
||||
keep-weekly: 52
|
||||
```
|
||||
|
||||
## Automatically forget after backup
|
||||
|
||||
You can also configure `autorestic` to automatically run the forget command for you after every backup. You can do that by specifying the `forget` option.
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
version: 2
|
||||
|
||||
locations:
|
||||
etc:
|
||||
from: /etc
|
||||
to: local
|
||||
forget: prune # Or only "yes" if you don't want to prune
|
||||
options:
|
||||
forget:
|
||||
keep-last: 5
|
||||
```
|
65
docs/pages/location/options/index.md
Normal file
65
docs/pages/location/options/index.md
Normal file
@ -0,0 +1,65 @@
|
||||
# Options
|
||||
|
||||
For the `backup` and `forget` commands you can pass any native flags to `restic`. In addition you can specify flags for every command with `all`.
|
||||
|
||||
If flags don't start with `-` they will get prefixed with `--`.
|
||||
|
||||
Flags without arguments can be set to `true`. They will be handled accordingly.
|
||||
|
||||
> ℹ️ It is also possible to set options for an [entire backend](/backend/options) or globally (see below).
|
||||
|
||||
```yaml
|
||||
locations:
|
||||
foo:
|
||||
# ...
|
||||
options:
|
||||
all:
|
||||
some-flag: 123
|
||||
# Equivalent to
|
||||
--some-flag: 123
|
||||
backup:
|
||||
boolean-flag: true
|
||||
tag:
|
||||
- foo
|
||||
- bar
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
In this example, whenever `autorestic` runs `restic backup` it will append a `--tag foo --tag bar` to the native command.
|
||||
|
||||
```yaml
|
||||
locations:
|
||||
foo:
|
||||
path: ...
|
||||
to: ...
|
||||
options:
|
||||
backup:
|
||||
tag:
|
||||
- foo
|
||||
- bar
|
||||
```
|
||||
|
||||
## Priority
|
||||
|
||||
Options can be set globally, on the backends or on the locations.
|
||||
|
||||
The priority is as follows: `location > backend > global`.
|
||||
|
||||
## Global Options
|
||||
|
||||
It is possible to specify global flags that will be run every time restic is invoked. To do so specify them under `global` in your config file.
|
||||
|
||||
```yaml
|
||||
global:
|
||||
all:
|
||||
cache-dir: ~/restic
|
||||
backup:
|
||||
tag:
|
||||
- foo
|
||||
|
||||
backends:
|
||||
# ...
|
||||
locations:
|
||||
# ...
|
||||
```
|
4
docs/pages/migration.md
Normal file
4
docs/pages/migration.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Migration
|
||||
|
||||
- [From 0.x to 1.0](/migration/0.x_1.0)
|
||||
- [From 1.4 to 1.5](/migration/1.4_1.5)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user