Giter Site home page Giter Site logo

offline-gmbh / scrubber Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 1.0 31 KB

Scrubber provides an easy way to clean up old files in a directory

Home Page: https://godoc.org/github.com/OFFLINE-GmbH/scrubber

License: MIT License

Go 100.00%
golang cleanup logrotation logging cross-platform

scrubber's Introduction

Scrubber

Build Status

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.

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 (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.
# Check your config and see what will be done
./scrubber -config scrubber.config.toml -pretend
# Execute the action
./scrubber -config scrubber.config.toml

scrubber's People

Contributors

tobias-kuendig avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

cryptobuks1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.