@@ -123,3 +123,97 @@ In the backup status the deactivated target is listed with D = Disabled and is g
BTW: the opposite way is possible to:
`./storage_helper.sh setactive`
# rest_pruner.sh
**!! This script is in version 0.1 - and work in progress !!**
The pruner script is for restic rest server with append only option. It can prune all repositories on server side.
## inc_config.sh
The inc_config.sh mus contain 3 variables for pruning
```bash
# for prune on restic rest server
prune_basedir=/netshare/restic-backup
prune_params="--group-by paths,tags --prune --keep-within 180d --max-unused unlimited --max-repack-size 100M --cleanup-cache"
prune_skipdays="7"
```
## rest_pruner.cfg
To access the different local repositories we need the RESTIC_PASSWORD for each repository.
The config file `rest_pruner.cfg` contains lines in the syntax
`<USER>:<RESTIC_PASSWORD>`
If a directory matches `${prune_basedir}/<USER>` then it will be pruned.
You need a mechanism to create this file eg. by Ansible.
For securiy reasons this file must be owned by root:root and must have the permissions 0400.
```txt
ls -l rest_pruner.cfg
-r--------. 1 root root 159 Feb 1 13:35 rest_pruner.cfg
```
## Syntax
```txt
========== RESTIC REST PRUNER v0.1 ==========
Pruner for restic rest server with append only option.
This script prunes all repositories on server side.
The config file [rest_pruner.cfg] contains <USER>:<RESTIC_PASSWORD>
If a directory matches /netshare/restic-backup/<USER> then it will be pruned.
SYNTAX:
rest_pruner.sh [OPTIONS] [FILTER]
OPTIONS:
-h, --help show help and exit.
PARAMETERS:
FILTER regex to filter directory list in
/netshare/restic-backup/*
EXAMPLES:
rest_pruner.sh
Start pruning of all matching repositories
rest_pruner.sh mail
Prune servers that match "mail",
eg. my-mailhub.example.com
```
## How does it work
It detects some requirements:
* was it started by root? (The help is shown without being root)
* permissions of rest_pruner.cfg
* variables from inc_config.sh
It loops over the starting dir `${prune_basedir}` and reads all its subdirectories.
If a subdir matches a configuration entry (text before first ":" `<USER>:<RESTIC_PASSWORD>`) then the prune process will be started. It detects the username of the owner of the directory and executes