Skip to content

Commit 31006a1

Browse files
author
Oliver Cervera
authored
Merge pull request #47 from auanasgheps/dev
Merge dev for 3.2 release
2 parents 40426da + d5b285b commit 31006a1

File tree

3 files changed

+183
-77
lines changed

3 files changed

+183
-77
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Contributions are welcome!
3232
- 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. During this step, the script will ensure drives are fine by reading parity and content files.
3333
- One of the following will happen:
3434
- 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.
35-
- 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. This is called "Sync with threshold warnings"
35+
- 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. This is called "Sync with threshold warnings"
36+
- Instead of forcing a sync based on the number of deleted files, you may consider the `ADD_DEL_THRESHOLD` feature, by allowing a sync that would otherwise violate the delete threshold, if the ratio of added to deleted files is greater than the value set.
3637
- If parity info is out of sync **but** the number of deleted or changed files did not exceed the threshold, it **executes a sync** to update the parity info.
3738
- 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. If sync was cancelled or other issues were found, scrub will not be run.
3839
- 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.
@@ -64,15 +65,21 @@ If you don't know what to do, I recommend using the default values and see how i
6465
- Sync always (forced sync).
6566
- Sync after a number of breached threshold warnings.
6667
- Sync only if thresholds warnings are not breached (enabled by default).
68+
- Sync even if the delete threshold has been breached, but the ratio of added to deleted files is greater than the value set.
6769
- User definable thresholds for deleted and updated files.
6870
- Scrub options
6971
- Enable or disable scrub job.
7072
- Delayed option, disabled by default. Run scrub only after a number of script executions, e.g. every 7 times. If you don't want to scrub your array every time, this one is for you.
7173
- Data to be scrubbed - by default 5% older than 10 days.
72-
- Pre-hashing - enabled by default. Mitigate the lack of ECC memory, reading data twice to avoid silent read errors.
74+
- Scrub new data - scrub the data that was just added by the sync.
75+
- Pre-hashing - enabled by default. Mitigate the lack of ECC memory, reading data twice to avoid silent read errors.
76+
- Force zero size sync - disabled by default. Forces the operation of syncing a file with zero size that before was not. Use with caution!
7377
- Snapraid Status - shows the status of the array, disabled by default.
7478
- SMART Log - enabled by default. A SnapRAID report for disks health status.
7579
- Verbosity option - disabled by default. When enabled, includes the TOUCH and DIFF commands output. Please note email will be huge and mostly unreadable.
80+
- SnapRAID Output (log) retention - disabled by default (log is overriden every run)
81+
- Detailed output retention for each run
82+
- You can choose the amount of days and the path, by default set to the user home
7683
- Healthchecks.io, Telegram and Discord integration
7784
- If you don't read your emails every day, this is a great one for you, since you can be quickly informed if things go wrong.
7885
- The script will report to Healthchecks.io, Telegram and Discord when is started and when is completed. If there's a failure it's included as well.
@@ -82,7 +89,7 @@ If you don't know what to do, I recommend using the default values and see how i
8289
- Made for external services or mail binaries with different commands than `mailx`.
8390
- Configure the path of the script or the mail binary to be invoked.
8491
- You can still use native services since it only replaces the standard email.
85-
- Container management - disabled by default.
92+
- Docker Container management
8693
- A list of containers you want to be interrupted before running actions and restored when completed.
8794
- Docker mode - choose to pause/unpause or to stop/restart your containers
8895
- Docker remote - if docker is running on a remote machine
@@ -98,7 +105,7 @@ You can also change more advanced options such SnapRAID binary location, log fil
98105
## A nice email report
99106
This script produces emails that don't contain a list of changed files to improve clarity.
100107

101-
You can re-enable full output in the email by switching the option `VERBOSITY`. The full report will always be available in `/tmp/snapRAID.out` but will be replaced after each run, or deleted when the system is shut down. You can change the location of the file if you need to keep it.
108+
You can re-enable full output in the email by switching the option `VERBOSITY`. The full report is available in `/tmp/snapRAID.out` but will be replaced after each run, or deleted when the system is shut down. You can enable the retention policy to keep logs for some days and customize the folder location.
102109

103110
Here's an example email report.
104111

@@ -279,7 +286,7 @@ If you start with empty disks, you cannot use (yet) this script, since it expect
279286
First run `snapraid sync`. Once completed, the array will be ready to be used with this script.
280287

281288
## OMV5/6 and SnapRAID plugin
282-
Ignore what you see at _OMV GUI > Services > SnapRAID > Diff Script Settings_, since it only applies to the plugin's built-in script. Also don't forget to remove the built-in `omv-snapraid-diff` script from _OMV GUI > System > Scheduled Tasks_, either by deleting the job, or simply disabling it.
289+
Ignore what you see at _OMV GUI > Services > SnapRAID > Diff Script Settings_, since it only applies to the plugin's built-in script. Also don't forget to remove the built-in `omv-snapraid-diff` job from _OMV GUI > System > Scheduled Tasks_, either by deleting the job, or simply disabling it.
283290

284291
## Installing `hd-idle` for Automatic Disk Spindown
285292
If you would like to enable automatic disk spindown after the script job runs, then you will need to install `hd-idle`. The version included in default Debian and Ubuntu repositories is buggy and out of date - fortunately developer [adelolmo](https://github.com/adelolmo/hd-idle) has improved the project and released an updated version.
@@ -318,3 +325,4 @@ This script would not exist without:
318325
- [nzlov](https://github.com/nzlov)
319326
- [Caedis](https://github.com/Caedis)
320327
- [Pushpender](https://github.com/ranapushpender)
328+
- [Phidauex](https://github.com/phidauex)

script-config.sh

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
CONFIG_VERSION=3.1
2+
CONFIG_VERSION=3.2
33
######################
44
# USER VARIABLES #
55
######################
@@ -8,15 +8,20 @@ CONFIG_VERSION=3.1
88

99
### NOTIFICATION SETTINGS ###
1010

11-
# address where the output of the jobs will be emailed to.
12-
EMAIL_ADDRESS="youremailgoeshere"
13-
FROM_EMAIL_ADDRESS="fromemailgoeshere"
11+
# Address where the output will be emailed to.
12+
# If you do not want to receive emails and rely on other notification
13+
# methods, leave these fields empty.
14+
EMAIL_ADDRESS="destination-email-goes-here"
15+
FROM_EMAIL_ADDRESS="sender-email-goes-here"
1416

1517
# Use Healthchecks.io to report script errors. Set to 1 to enable.
1618
# Please note that every "WARNING" will be reported as failure.
1719
# When enabled, enter your Healthchecks UUID (not the full URL).
20+
# If using a self-hosted instance, change the URL to your endpoint
21+
# including the trailing slash.
1822
HEALTHCHECKS=0
1923
HEALTHCHECKS_ID="your-uuid-here"
24+
HEALTHCHECKS_URL="https://hc-ping.com/"
2025

2126
# Use Telegram to report script execution summary (not the whole report)
2227
# Set 1 to enable. Create a bot using @botfather, then copy the API token.
@@ -45,26 +50,37 @@ HOOK_NOTIFICATION=""
4550

4651
### SCRIPT AND SNAPRAID SETTINGS ###
4752

48-
# Set the threshold of deleted files to stop the sync job from running. Note
49-
# that depending on how active your filesystem is being used, a low number here
50-
# may result in your parity info being out of sync often and/or you having to
51-
# do lots of manual syncing.
53+
# Set the threshold of deleted and updated files to stop the sync job from running.
54+
# Note that depending on how active your filesystem is being used, a low number
55+
# here may result in your parity info being out of sync often and/or you having
56+
# to do lots of manual syncing.
5257
DEL_THRESHOLD=500
5358
UP_THRESHOLD=500
5459

60+
# Allow a sync that would otherwise violate the delete threshold, but only
61+
# if the ratio of added to deleted files is greater than the value set.
62+
# Set to 0 to disable this option.
63+
# Example: A senario with 5000 deleted files and 3800 added files would
64+
# result in an ADD_DEL_THRESHOLD of 0.76 (3800/5000)
65+
ADD_DEL_THRESHOLD=0
66+
5567
# Set number of warnings before we force a sync job. This option comes in handy
5668
# when you cannot be bothered to manually start a sync job when DEL_THRESHOLD
5769
# is breached due to false alarm. Set to 0 to ALWAYS force a sync (i.e. ignore
5870
# the delete threshold above) Set to -1 to NEVER force a sync (i.e. need to
5971
# manual sync if delete threshold is breached).
6072
SYNC_WARN_THRESHOLD=-1
6173

62-
# Set percentage of array to scrub if it is in sync. i.e. 0 to disable and 100
63-
# to scrub the full array in one go WARNING - depending on size of your array,
64-
# setting to 100 will take a very long time!
74+
# Set percentage and age, in days, of blocks in array to scrub if it is in sync.
75+
# i.e. 0 to disable and 100 to scrub the full array in one go.
76+
# WARNING - depending on size of your array, setting to 100 can take a long time!
6577
SCRUB_PERCENT=5
6678
SCRUB_AGE=10
6779

80+
# Scrub new blocks after sync that have yet to be scrubbed. 1 to enable and any
81+
# other value to disable.
82+
SCRUB_NEW=0
83+
6884
# Set number of script runs before running a scrub. Use this option if you
6985
# don't want to scrub the array every time.
7086
# Set to 0 to disable this option and run scrub every time.
@@ -77,6 +93,13 @@ SCRUB_DELAYED_RUN=0
7793
# allow to run a fix operation. 1 to enable, any other value to disable.
7894
PREHASH=1
7995

96+
# Forces the operation of syncing a file with zero size that before was not.
97+
# If SnapRAID detects a such condition, it stops proceeding unless you enable
98+
# this option. Useful when syncing system files which can genuinely get
99+
# changed to zero.
100+
# Disabled by default, 1 to enable.
101+
FORCE_ZERO=0
102+
80103
# Set if disk spindown should be performed. Depending on your system, this may
81104
# not work. 1 to enable, any other value to disable.
82105
# hd-idle is required and must be already configured.
@@ -86,12 +109,22 @@ SPINDOWN=0
86109
# other value to disable.
87110
SMART_LOG=1
88111

89-
# Increase verbosity of the email output. If set to 1, TOUCH and DIFF outputs
90-
# will be kept in the email, producing a mostly unreadable email. Keep this
91-
# disabled for optimal results. You can always check TOUCH and DIFF outputs
92-
# using the TMP file. 1 to enable, any other value to disable.
112+
# Increase verbosity of the email output. NOT RECOMMENDED!
113+
# If set to 1, TOUCH and DIFF outputs will be kept in the email, producing
114+
# a mostly unreadable email. You can always check TOUCH and DIFF outputs
115+
# using the TMP file or use the feature KEEP_LOG.
116+
# 1 to enable, any other value to disable.
93117
VERBOSITY=0
94118

119+
# SnapRAID detailed output retention for each run.
120+
# Default behaviour is RETENTION_DAYS=0: every time your run SnapRAID, the
121+
# output is saved to "/tmp" and is overridden during every run.
122+
# To enable retention, set RETENTION_DAYS to the days of output you want to
123+
# keep in your home folder. Files will have timestamps.
124+
# SNAPRAID_LOG_DIR can be changed to any folder you like.
125+
RETENTION_DAYS=0
126+
SNAPRAID_LOG_DIR="$HOME"
127+
95128
# Run 'snapraid status' command to show array general information.
96129
# 1 to enable, any other value to disable.
97130
SNAP_STATUS=0
@@ -132,7 +165,7 @@ DOCKER_DELAY=10
132165

133166
# Hooks are shell commands that the scripts executes for you.
134167
# You can specify 'before_hook' to perform preparation steps before SnapRAID
135-
# actions and specify 'after_hook' to perform steps afterwards.
168+
# actions and 'after_hook' to perform steps afterwards.
136169

137170
# Set to 1 to enable custom hooks
138171
CUSTOM_HOOK=0

0 commit comments

Comments
 (0)