https://github.com/offline-gmbh/scrubber
Scrubber provides an easy way to clean up old files in a directory
https://github.com/offline-gmbh/scrubber
cleanup cross-platform golang logging logrotation
Last synced: about 1 year ago
JSON representation
Scrubber provides an easy way to clean up old files in a directory
- Host: GitHub
- URL: https://github.com/offline-gmbh/scrubber
- Owner: OFFLINE-GmbH
- License: mit
- Created: 2018-08-18T15:00:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-24T15:55:23.000Z (almost 3 years ago)
- Last Synced: 2025-05-31T10:26:38.075Z (about 1 year ago)
- Topics: cleanup, cross-platform, golang, logging, logrotation
- Language: Go
- Homepage: https://godoc.org/github.com/OFFLINE-GmbH/scrubber
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scrubber
[](https://travis-ci.org/OFFLINE-GmbH/scrubber)
Scrubber provides an easy way to clean up old files in a directory.
It is especially useful on platforms where `logrotate` is not easily available or disk space is sparse.
## Configuration
You can specify directories to clean up in a `toml` configuration file. You can define one or more strategies used for
each directory.
```toml
title = "Log scrubber example config"
[[directory]]
name = "Apache Logs"
path = "/var/logs/apache"
exclude = ["zip"]
[[directory.strategy]]
type = "size"
action = "delete"
limit = "100M"
[[directory.strategy]]
type = "age"
action = "delete"
limit = "1y"
[[directory.strategy]]
type = "age"
action = "zip"
limit = "1d"
[[directory]]
name = "Backups"
path = "/var/backups/yourapp"
include = ["tar.gz"]
[[directory.strategy]]
type = "age"
action = "delete"
limit = "1y"
```
### Directory
The following options are available for each `directory`:
| Option | Description |
|-------------|---------------------------------------------------------------------------------------------------------------------------------|
| name | A descriptive name for this directory. |
| path | The full path to the directory. Can be a [`Glob` expression](https://pkg.go.dev/path/filepath#Glob) (like `/path/*/subfolder`). |
| include | (Optional) Define what files should be included. All files without a matching extension will be ignored. |
| exclude | (Optional) Define what files should be excluded. All files with matching extension will be ignored. |
| keep_latest | Any , leave the latest `n` files untouched. |
You can either specify a `include` or a `exclude` rule but never both.
### Strategy
The following options are available for each `strategy`:
| Option | Possible values | Description |
|-------------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| type | `age` and `size` | If the files should be selected by their `age` (last modified) or their `size`. |
| action | `delete` and `zip` | If matching files should be deleted or zipped. The `zip` action will remove the original file. Make sure to also exclude `zip` files from this rule so created zip files won't be cleaned up on subsequent runs. |
| limit | A file size or age | Define the max. age as `1y`, `1d`, `2h` or the file size as `1M`, `1GB`, `1000B`. Supported units for the age are `m`, `h`, `d`, `w`, `y`. Supported units for the size are `B`, `KB`, `MB`, `GB`, `TB`, `PB`. |
## Run
You can run `scrubber` from the command line. The following options are available:
| Param | Default | Description |
|----------|----------------------|---------------------------------------------------------------|
| -config | scrubber.config.toml | The path to your configuration file. |
| -pretend | false | If specified, scrubber will log actions but not execute them. |
```bash
# Check your config and see what will be done
./scrubber -config scrubber.config.toml -pretend
# Execute the action
./scrubber -config scrubber.config.toml
```