1
0
Fork 0
Mizule is a simple tool that checks the UUID of a mounted filesystem and issues a warning if it has not changed recently.
Go to file
Dustin a58a04c350 Send notifications with Matrix
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.
2021-08-23 11:53:21 -05:00
src Send notifications with Matrix 2021-08-23 11:53:21 -05:00
.gitignore Initial commit 2020-01-17 19:15:13 -06:00
Cargo.lock Send notifications with Matrix 2021-08-23 11:53:21 -05:00
Cargo.toml Send notifications with Matrix 2021-08-23 11:53:21 -05:00
README.md Initial commit 2020-01-17 19:15:13 -06:00
rustfmt.toml Initial commit 2020-01-17 19:15:13 -06:00

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.