auanasgheps / snapraid-aio-script

The definitive all-in-one SnapRAID script on Linux. Diff, sync, scrub are things of the past. Manage SnapRAID and much, much more!
GNU General Public License v3.0
241 stars 36 forks source link

Add verbosity option 2: Include TOUCH and DIFF output in email (only) if no sync was run because of failed checks (deleted or updated files threshold has been reached or exceeded). #121

Open DonkeeeyKong opened 2 months ago

DonkeeeyKong commented 2 months ago

Description

This adds the option to set VERBOSITY to 2. Setting this will send a mail with the full diff and touch output when the deleted or updated files threshold has been reached or exceeded and no sync was run because of that. It will trim the log in all other cases. This can be useful if you want to check the list of changed files before running a manual sync every time no automatic sync was run and don't want to bother checking the log via command line.

Type of change

Checklist:

auanasgheps commented 2 months ago

I like the idea to show touch and diff output when thresholds are breached, but the email can get extremely long.

I've thought about it in the past and my conclusions have always leaned towards creating an email attachment of these specific outputs (maybe a file for each output), so the email is still readable. I still haven't looked into this, but I'm sure it's possible and it should not be too much work and we can still use parts of this work.

What do you think?

DonkeeeyKong commented 2 months ago

That would be a better option. I have a threshold of 500 files and that was only ever breached by 10 or 20, so the list wasn't too long. This can of course be very different for other situations...

However: I have looked a little bit into it: Adding an attachment is not as easily done as just sending a mail.

mailx can be a variety of programs, that have different ways to attach a file (sometimes it's -a, sometimes its -A, sometimes it's not possible): https://askubuntu.com/questions/1148615/neither-mail-nor-mutt-sends-emails-with-file-attaches

I am using openmediavault and on my system mail/mailx is provided by bsd-mailx, which has no functionality to send attachments: https://manpages.debian.org/bookworm/bsd-mailx/bsd-mailx.1.en.html bsd-mailx is a dependency of openmediavault, so this is the default: https://github.com/openmediavault/openmediavault/blob/3a7d23c61699a33199b4e8edafb8cdf27d2fbe8b/deb/openmediavault/debian/control#L15C1-L15C68

mailutils' mailx on Debian apparently has this functionality: https://manpages.debian.org/bookworm/mailutils/mail.mailutils.1.en.html#A

So this would require to make sure a specific program, e.g. mailutils is used for mail (or setting up (and configuring?) a whole different one like mutt) – and that's only Debian. :D

I am not sure if this doesn't make it too complicated...

DonkeeeyKong commented 2 months ago

We could also add another option to have the output send in a separate mail. So people can receive a readable standard email and a separate email with the long output, if they prefer that.