-
Notifications
You must be signed in to change notification settings - Fork 62
v3_tuto_cleanup
Thomas Leibovici edited this page Aug 2, 2016
·
19 revisions
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'.
- 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.
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 (using target_fileclass statement) and time-bases conditions (in a condition block).
- You can optionally define a default policy rule to apply to entries that don't match any target fileclass.
cleanup_rules { ignore { last_access < 1d } ignore_fileclass = empty_files; 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 } } }
Back to wiki home