mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-05 18:10:40 +00:00
Fix #2: support pruning and forget via snapshot policies
This commit is contained in:
57
README.md
57
README.md
@@ -10,6 +10,7 @@ Autorestic is a wrapper around the amazing [restic](https://restic.net/). While
|
||||
- Config files, no CLI
|
||||
- Predictable
|
||||
- Backup locations to multiple backends
|
||||
- Snapshot policies and pruning
|
||||
- Simple interface
|
||||
- Fully encrypted
|
||||
|
||||
@@ -32,7 +33,7 @@ locations:
|
||||
home:
|
||||
from: /home/me
|
||||
to: remote
|
||||
|
||||
|
||||
important:
|
||||
from: /path/to/important/stuff
|
||||
to:
|
||||
@@ -45,7 +46,7 @@ backends:
|
||||
path: 'myBucket:backup/home'
|
||||
B2_ACCOUNT_ID: account_id
|
||||
B2_ACCOUNT_KEY: account_key
|
||||
|
||||
|
||||
hdd:
|
||||
type: local
|
||||
path: /mnt/my_external_storage
|
||||
@@ -57,7 +58,7 @@ Then we check if everything is correct by running the `check` command. We will p
|
||||
autorestic check -a
|
||||
```
|
||||
|
||||
If we would check only one location we could run the following: `autorestic -l home check`.
|
||||
If we would check only one location we could run the following: `autorestic -l home check`.
|
||||
|
||||
### Backup
|
||||
|
||||
@@ -108,7 +109,7 @@ For each backend you need to specify the right variables as shown in the example
|
||||
##### `path`
|
||||
|
||||
The path on the remote server.
|
||||
For object storages as
|
||||
For object storages as
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -121,9 +122,55 @@ backends:
|
||||
B2_ACCOUNT_KEY: backblaze_account_key
|
||||
```
|
||||
|
||||
## Pruning and snapshot 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:
|
||||
|
||||
```yaml
|
||||
locations:
|
||||
etc:
|
||||
from: /etc
|
||||
to: local
|
||||
keep:
|
||||
# options matches the --keep-* options used in the restic forget CLI
|
||||
# cf https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy
|
||||
last: 5 # always keep at least 5 snapshots
|
||||
hourly: 3 # keep 3 last hourly shapshots
|
||||
daily: 4 # keep 4 last daily shapshots
|
||||
weekly: 1 # keep 1 last weekly shapshots
|
||||
monthly: 12 # keep 12 last monthly shapshots
|
||||
yearly: 7 # keep 7 last yearly shapshots
|
||||
within: "2w" # keep snapshots from the last 2 weeks
|
||||
```
|
||||
|
||||
Pruning can be triggered using `autorestic forget -a`, for all locations, or selectively with `autorestic forget -l <location>`. **please note that contrary to the restic CLI, `restic forget` will call `restic prune` internally.**
|
||||
|
||||
|
||||
|
||||
Run with the `--dry-run` flag to only print information about the process without actually pruning the snapshots. This is especially useful for debugging or testing policies:
|
||||
|
||||
```
|
||||
$ autorestic forget -a --dry-run --verbose
|
||||
|
||||
Configuring Backends
|
||||
local : Done ✓
|
||||
|
||||
Removing old shapshots according to policy
|
||||
etc ▶ local : Removing old spnapshots… ⏳
|
||||
etc ▶ local : Running in dry-run mode, not touching data
|
||||
etc ▶ local : Forgeting old snapshots… ⏳Applying Policy: all snapshots within 2d of the newest
|
||||
keep 3 snapshots:
|
||||
ID Time Host Tags Reasons Paths
|
||||
-----------------------------------------------------------------------------
|
||||
531b692a 2019-12-02 12:07:28 computer within 2w /etc
|
||||
51659674 2019-12-02 12:08:46 computer within 2w /etc
|
||||
f8f8f976 2019-12-02 12:11:08 computer within 2w /etc
|
||||
-----------------------------------------------------------------------------
|
||||
3 snapshots
|
||||
```
|
||||
|
||||
##### Note
|
||||
|
||||
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 somewhere in case your server dies. Otherwise DATA IS LOST!
|
||||
|
||||
|
Reference in New Issue
Block a user