Skip to content

v3_tuto_cleanup

Thomas Leibovici edited this page Aug 2, 2016 · 19 revisions

Polcies: cleaning old entries

This tutorial explains how to setup a cleanup policy to purge old entries in a filesystem.

Note: in robinhood v2.x this was previously implemented as the purge policy of 'robinhood-tmpfs'.

Configuration

  • First include 'tmpfs.inc' in your config file. This defines a 'cleanup' policy:
 %include "includes/tmpfs.inc"
  • Specify your policy targets as fileclasses. Fileclass definitions must ba based on rather static criteria (like owner, path, group...), but should not be based on time criteria (age of last access, last modification, etc.). Time-based criteria will be specified in policy rules.
Examples:
 fileclass log_files {
     definition { type == file and name == "*.log"
                  and tree == "/path/to/logs" }
 }
 fileclass trash {
     definition { tree == "/path/to/trash/" }
 }
  • Then specify cleanup rules:
    • To speed up policy run, you can define entries to be ignored using 'ignore' or 'ignore_fileclass' statements (note: only 'ignore' statements with simple expressions like "crit comp value" result in policy run optimlizations, e.g. last_mod < 1d).
    • In policy rule, specify target fileclasses and time-bases conditions.
    • You can optionally define a 'default' policy rule to apply to entries that don't match any target fileclass.
Example:
    rule clean_some_files {
        target_fileclass = log_files;
        target_fileclass = foo_files;
        condition { last_mod > 7d }
    }
 
    rule clean_other_files {
        target_fileclass = user_files;
        target_fileclass = bar;
        condition { last_access > 30d }
    }
 
    # default rule (optional):
    # apply to all other entries
    rule default {
        condition { last_access > 60d }
    }
 }
Clone this wiki locally