If the UUID of the mounted filesystem is different than the cached UUID for that filesystem, the cache needs to be updated with the new value. Otherwise, the program will continually emit warnings once the cached entry expires, regardless of whether or not the filesystem has changed in that time. |
||
---|---|---|
src | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
README.md | ||
rustfmt.toml |
README.md
Mizule
Mizule is a simple tool that checks the UUID of the filesystem mounted at the specified path, and issues a warning if it has not changed within a given time period (default 30 days). This is useful, for example, to remind backup operators to switch out the backup disk periodically.
Usage
Check /var/spool/burp
and warn if it has not changed in the last 30 days:
mizule /var/spool/burp
Check /var/spool/burp
and warn if it has not changed in the last 10 days,
sending an email to burp-admin@example.org
:
mizule /var/spool/burp --ttl 30 --mailto burp-admin@example.org
Cache File
Mizule keeps track of the UUID of each of the filesystems it has seen in a
cache file. This file is stored at ${XDG_CACHE_HOME}/mizule.json
. If the
XDG_CACHE_HOME
environment variable is not set, ${HOME}/.cache
is used. If
the HOME
environment variable is also not set, the cache file will be created
in the current working directory.
Periodic Check with systemd Timer Unit
Mizule works best if it is scheduled to check the filesystem periodically. One way to set up this schedule is to use a systemd timer unit.
mizule@.service
:
[Unit]
Description=Check last filesystem change for %I
RequiresMountsFor=%I
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
Environment=XDG_CACHE_HOME=/var/cache/mizule
ExecStart=/usr/local/bin/mizule %I --mailto burp-admin@example.org
mizule@.timer
:
[Unit]
Description=Schedule filesystem check for %I
[Timer]
OnBootSec=5m
OnUnitInactiveSec=12h
[Install]
WantedBy=multi-user.target
To enable:
systemctl enable mizule@-var-spool-burp.timer
This will trigger the check 5 minutes after the machine boots, and then again every 12 hours.