You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,37 +4,188 @@ The definitive all-in-one [SnapRAID](https://github.com/amadvance/snapraid) scri
4
4
There are many SnapRAID scripts out there, but none could fit my needs. So I took the best of them to start a new one.
5
5
6
6
It is meant to be run periodically (e.g. daily) and do the heavy lifting, then send an email you will actually read.
7
-
It is highly customizable.
8
-
It has been tested with Debian 10 and OpenMediaVault 5.
7
+
8
+
Supports single and dual parity configurations.
9
+
10
+
It is customizable and has been tested with Debian 10 and OpenMediaVault 5.
9
11
10
12
Contributions are welcome: there's always room for improvement!
11
13
12
-
This readme has some rough edges which will be smoothened over time.
14
+
_This readme has some rough edges which will be smoothened over time._
15
+
16
+
# Highlights
17
+
18
+
## How it works
19
+
- After some preliminary checks, the script will execute `snapraid diff` to figure out if parity info is out of date, which means checking for changes since the last execution.
20
+
- One of the following will happen:
21
+
- If parity info is out of sync **and** the number of deleted or changed files exceed the threshold you have configured it **stops**. You may want to take a look to the output log.
22
+
- If parity info is out of sync **and** the number of deleted or changed files exceed the threshold, you can still **force a sync** after a number of warnings. It's useful If you often get a false alarm but you're confident enough.
23
+
- If parity info is out of sync **but** the number of deleted or changed files did not exceed the treshold, it **executes a sync** to update the parity info.
24
+
- When the parity info is in sync, either because nothing has changed or after a successfully sync, it runs the `snapraid scrub` command to validate the integrity of the data, both the files and the parity info. _Note that each run of the scrub command will validate only a configurable portion of parity info to avoid having a long running job and affecting the performance of the server._
25
+
- When the script is done sends an email with the results, both in case of error or success.
26
+
27
+
Pre-hashing is enabled by default to avoid silent read errors. It mitigates the lack of ECC memory.
28
+
29
+
## A nice email report
30
+
This report produces emails that don't contain a list of changed files to improve clarity.
31
+
32
+
You can re-enable full output in the email by switching the option `VERBOSITY` but the full report will always be available in `/tmp/snapRAID.out` and will be replaced after each run or deleted when the system is shut down if kept there.
33
+
34
+
SMART drive report from SnapRAID is also included by default.
35
+
36
+
Here's a sneak peek of the email report.
37
+
38
+
```markdown
39
+
## [COMPLETED] DIFF + SYNC + SCRUB Jobs (SnapRAID on omv-test.local)
40
+
41
+
SnapRAID Script Job started [Sat Jan 9 02:07:46 CET 2021]
42
+
Running SnapRAID version 11.5
43
+
SnapRAID Script version 2.7.0
44
+
45
+
----------
46
+
47
+
## Preprocessing
48
+
49
+
Configuration file found! Proceeding.
50
+
Testing that all parity files are present.
51
+
All parity files found. Continuing...
52
+
53
+
----------
54
+
55
+
## Processing
56
+
57
+
### SnapRAID TOUCH [Sat Jan 9 02:07:46 CET 2021]
58
+
59
+
Checking for zero sub-second files.
60
+
No zero sub-second timestamp files found.
61
+
TOUCH finished [Sat Jan 9 02:07:46 CET 2021]
62
+
63
+
### SnapRAID DIFF [Sat Jan 9 02:07:46 CET 2021]
64
+
65
+
DIFF finished [Sat Jan 9 02:07:46 CET 2021]
66
+
67
+
**SUMMARY of changes - Added [2] - Deleted [0] - Moved [0] - Copied [0] - Updated [0]**
68
+
69
+
There are deleted files. The number of deleted files, (0), is below the threshold of (2). SYNC Authorized.
70
+
There are updated files. The number of updated files, (0), is below the threshold of (2). SYNC Authorized.
71
+
72
+
### SnapRAID SYNC [Sat Jan 9 02:07:46 CET 2021]
73
+
74
+
Self test...
75
+
Loading state from /srv/dev-disk-by-label-DISK1/snapraid.content...
76
+
Scanning disk DATA1...
77
+
Scanning disk DATA2...
78
+
Using 0 MiB of memory for the file-system.
79
+
Initializing...
80
+
Hashing...
81
+
SYNC_JOB--Everything OK
82
+
Resizing...
83
+
Saving state to /srv/dev-disk-by-label-DISK1/snapraid.content...
84
+
Saving state to /srv/dev-disk-by-label-DISK2/snapraid.content...
85
+
Saving state to /srv/dev-disk-by-label-DISK3/snapraid.content...
86
+
Saving state to /srv/dev-disk-by-label-DISK4/snapraid.content...
####################### USER CONFIGURATION START #######################
7
+
8
+
# address where the output of the jobs will be emailed to.
9
+
EMAIL_ADDRESS="youremailgoeshere"
10
+
11
+
# Set the threshold of deleted files to stop the sync job from running.
12
+
# NOTE that depending on how active your filesystem is being used, a low
13
+
# number here may result in your parity info being out of sync often and/or
14
+
# you having to do lots of manual syncing.
15
+
DEL_THRESHOLD=500
16
+
UP_THRESHOLD=500
17
+
18
+
# Set number of warnings before we force a sync job.
19
+
# This option comes in handy when you cannot be bothered to manually
20
+
# start a sync job when DEL_THRESHOLD is breached due to false alarm.
21
+
# Set to 0 to ALWAYS force a sync (i.e. ignore the delete threshold above)
22
+
# Set to -1 to NEVER force a sync (i.e. need to manual sync if delete threshold is breached)
23
+
SYNC_WARN_THRESHOLD=-1
24
+
25
+
# Set percentage of array to scrub if it is in sync.
26
+
# i.e. 0 to disable and 100 to scrub the full array in one go
27
+
# WARNING - depending on size of your array, setting to 100 will take a very long time!
28
+
SCRUB_PERCENT=5
29
+
SCRUB_AGE=10
30
+
31
+
# Prehash Data To avoid the risk of a latent hardware issue, you can enable the "pre-hash" mode and have all the
32
+
# data read two times to ensure its integrity. This option also verifies the files moved inside the array, to ensure
33
+
# that the move operation went successfully, and in case to block the sync and to allow to run a fix operation.
34
+
# 1 to enable, any other values to disable
35
+
PREHASH=1
36
+
37
+
# Set the option to log SMART info. 1 to enable, any other value to disable
38
+
SMART_LOG=1
39
+
40
+
# Set verbosity of the email output. TOUCH and DIFF outputs will be kept in the email, producing a potentially huge email. Keep this disabled for optimal reading
41
+
# You can always check TOUCH and DIFF outputs using the TMP file.
42
+
# 1 to enable, any other values to disable
43
+
VERBOSITY=0
44
+
45
+
# Set if disk spindown should be performed. Depending on your system, this may not work. 1 to enable, any other values to disable
46
+
SPINDOWN=0
47
+
48
+
# Run snapraid status command to show array general information.
49
+
# Be aware the HTML output is pretty broken.
50
+
SNAP_STATUS=0
51
+
52
+
# location of the snapraid binary
53
+
SNAPRAID_BIN="/usr/bin/snapraid"
54
+
# location of the mail program binary
55
+
MAIL_BIN="/usr/bin/mailx"
56
+
57
+
####################### USER CONFIGURATION END #######################
58
+
59
+
####################### SYSTEM CONFIGURATION #######################
0 commit comments