Deploy FileCleaner with Docker and systemd¶
Refer to CLI Commands and Exit Codes before you start this procedure.
Prerequisites¶
- Make sure that you have
sudoor root access on the Linux host. - Make sure that Docker Engine or
systemdis active on the host. - Prepare
/etc/filecleaner,/var/lib/filecleaner, and/var/log/filecleanerdirectories.
Safety Instructions¶
CAUTION: Set dry_run = true in new configuration files before you start the service.
Rules with dry_run = false immediately compress, move, or delete files.
Procedure¶
- Create
/etc/filecleaner/filecleaner.tomlwithdry_run = trueand a validated rule:
dry_run = true
global_trash_dir = "/var/tmp/filecleaner-trash"
[daemon]
mode = "hybrid"
interval = "5m"
watch = true
debounce = "2s"
sweep_on_start = true
pid_file = "/var/lib/filecleaner/filecleaner.pid"
state_file = "/var/lib/filecleaner/state.json"
stop_file = "/var/lib/filecleaner/filecleaner.stop"
[audit]
log_path = "/var/log/filecleaner/audit.jsonl"
jsonl = true
[[rules]]
name = "app-backups"
path = "/var/backups/app"
recursive = false
follow_symlinks = false
include_globs = ["*.sql", "*.dump"]
max_files = 14
max_age = "30d"
actions = ["compress", "move"]
compression = "gzip"
move_to = "/mnt/cold-archive/app"
[rules.backup_guard]
enabled = true
min_keep_files = 3
min_valid_backup_bytes = "1MiB"
require_newer_within = "36h"
freeze_on_empty_valid = true
- Restrict permissions on the configuration file to owner read and write:
- Validate the configuration file before you start any container or service:
- Run a read-only sweep plan to examine projected decisions:
- For a Docker deployment, set UID
10001and GID10001on the configuration and host volumes:
sudo chown 10001:10001 /etc/filecleaner/filecleaner.toml
sudo chown -R 10001:10001 /var/lib/filecleaner /var/log/filecleaner /var/backups/app /mnt/cold-archive/app
- Pull the official Docker container image:
- Start container
filecleaner-daemonwith the mounted configuration and volume paths:
docker run -d \
--name filecleaner-daemon \
--restart unless-stopped \
-v /etc/filecleaner:/etc/filecleaner:ro \
-v /var/backups/app:/var/backups/app \
-v /mnt/cold-archive/app:/mnt/cold-archive/app \
-v /var/lib/filecleaner:/var/lib/filecleaner \
-v /var/log/filecleaner:/var/log/filecleaner \
jmrenouard/filecleaner:v1.0.1 \
daemon run --config /etc/filecleaner/filecleaner.toml
- For a host
systemddeployment, generate/etc/systemd/system/filecleaner.serviceand enable the unit:
sudo filecleaner daemon service-template \
--init-system systemd \
--config /etc/filecleaner/filecleaner.toml \
--output /etc/systemd/system/filecleaner.service
sudo systemctl daemon-reload
sudo systemctl enable --now filecleaner
- Change
dry_run = truetodry_run = falsein/etc/filecleaner/filecleaner.toml, then restart the service.
NOTE: The official Docker image runs as non-root UID and GID 10001.
Mounted host files and directories must permit UID 10001 access.
Verification¶
- Examine container or
systemdunit status:
- Run
filecleaner daemon statusand confirm exit code0:
- Examine
/var/log/filecleaner/audit.jsonland make sure thatsweep_endrecords appear.
Rollback¶
If an error occurs after deployment, do these steps:
- Stop the Docker container or
systemdservice:
docker stop filecleaner-daemon && docker rm filecleaner-daemon
sudo systemctl disable --now filecleaner
- If a stale PID remains, run
filecleaner daemon stopwith a timeout:
- Replace
/etc/filecleaner/filecleaner.tomlwith the previous valid configuration file. - Start the previous service version and confirm healthy
daemon statusoutput.
Related Documentation¶
- Reference: CLI Commands and Exit Codes
- Reference: Configuration Schema and Invariants
- Explanation: Fail-Closed 6-Phase Pipeline
- Explanation: ADR-001: Pure-Rust Fail-Closed Engine