I don't pay enough attention to e-mail notifications any more, since I no longer get alerts for them on my phone. I do get Matrix notifications, though, through Element, and that seems to work well as a reminder for me. Matrix is of course a lot more complex than e-mail. It is a stateful protocol that requires (at least) keeping authentication and/or session information on the client. Technically, clients all have a "device ID," which they should use any time they communicate with the server. I decided it makes the most sense to keep this value in the same cache file as the filesystem UUIDs and timestamps. I prefer reading usernames and passwords from a configuration file over passing them as command-line arguments, so I added that ability as well. |
||
---|---|---|
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.