Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash helper script to help with the automation of routine snapRAID tasks. Add it as a cron job to automate the routine tasks of running sync and scrub. Script will optionally send you email of status and issues encountered during the run.
#!/bin/bash
#######################################################################
# This is a helper script that keeps snapraid parity info in sync with
# your data and optionally verifies the parity info. Here's how it works:
# 1) Checks for size 0 .nfo files (plex)
# 2) Calls diff to figure out if the parity info is out of sync.
# 3) If parity info is out of sync, AND the number of deleted or changed files exceed
# X (each configurable), it triggers an alert email and stops. (In case of
# accidental deletions, you have the opportunity to recover them from
# the existing parity info. This also mitigates to a degree encryption malware.)
# 4) If partiy info is out of sync, AND the number of deleted or changed files exceed X
# AND it has reached/exceeded Y (configurable) number of warnings, force
# a sync. (Useful when you get a false alarm above and you can't be bothered
# to login and do a manual sync. Note the risk is if its not a false alarm
# and you can't access the box before Y number of times the job is run to
# fix the issue... Well I hope you have other backups...)
# 5) If parity info is out of sync BUT the number of deleted files did NOT
# exceed X, it calls sync to update the parity info.
# 6) If the parity info is in sync (either because nothing changed or after it
# has successfully completed the sync job, it runs the 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 box.
# 7) Once all jobs are completed, it sends an email with the output to user
# (if configured).
#
#
# Inspired by Zack Reed (http://zackreed.me/articles/83-updated-snapraid-sync-script)
#
#######################################################################
# REQUIRES:
# - mailx (simplify sending HTML emails)
# - python markdown (render Markdown to HTML)
######################
# USER VARIABLES #
######################
####################### USER CONFIGURATION START #######################
# address where the output of the jobs will be emailed to.
# comment it out to disable email output
EMAIL_ADDRESS="root"
# Set the threshold of deleted files to stop the sync job from running.
# NOTE that depending on how active your filesystem is being used, a low
# number here may result in your parity info being out of sync often and/or
# you having to do lots of manual sync.
DEL_THRESHOLD=100
UP_THRESHOLD=500
# Set number of warnings before we force a sync job.
# This option comes in handy when you cannot be bothered to manually
# start a sync job when DEL_THRESHOLD is breached due to false alarm.
# Set to 0 to ALWAYS force a sync (i.e. ignore the delete threshold above)
# Set to -1 to NEVER force a sync (i.e. need to manual sync if delete threshold is breached)
#SYNC_WARN_THRESHOLD=3
SYNC_WARN_THRESHOLD=-1
# Set percentage of array to scrub if it is in sync.
# i.e. 0 to disable and 100 to scrub the full array in one go
# WARNING - depending on size of your array, setting to 100 will take a very long time!
SCRUB_PERCENT=10
SCRUB_AGE=10
# Set the option to log SMART info. 1 to enable, any other values to disable
SMART_LOG=1
# location of the snapraid binary
SNAPRAID_BIN="/usr/bin/snapraid"
# location of the mail program binary
MAIL_BIN="/usr/bin/mailx"
##### USER CONFIGURATION STOP ##### MAKE NO CHANGES BELOW THIS LINE ####
function main(){
######################
# INIT VARIABLES #
######################
CHK_FAIL=0
DO_SYNC=0
EMAIL_SUBJECT_PREFIX="(SnapRAID on `hostname`)"
GRACEFUL=0
SOPHOS_RUNNING=0
SYNC_WARN_FILE="/tmp/snapRAID.warnCount"
SYNC_WARN_COUNT=""
TMP_OUTPUT="/tmp/snapRAID.out"
# Capture time
SECONDS=0
# Expand PATH for smartctl
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# auto determine names of content and parity files
CONTENT_FILE=`grep -v '^$\|^\s*\#' /etc/snapraid.conf | grep snapraid.content | head -n 1 | cut -d " " -f2`
PARITY_FILE=`grep -v '^$\|^\s*\#' /etc/snapraid.conf | grep snapraid.parity | head -n 1 | cut -d " " -f2`
# redirect all output to screen and file
> $TMP_OUTPUT
exec 3>&1 4>&2
# NOTE: Not preferred format but valid: exec &> >(tee -ia "${TMP_OUTPUT}" )
exec > >(tee -ia "${TMP_OUTPUT}" ) 2>&1
# timestamp the job
echo "SnapRAID Script Job started [`date`]"
echo
echo "----------------------------------------"
# Remove any plex created anomolies
echo "##Preprocessing"
# Stop any services that may inhibit optimum execution
echo "###Stop Services [`date`]"
stop_services
echo "###Remove Zero Byte NFOs [`date`]"
echo "Removing any 0 byte .nfo's before SnapRAID exeuction."
find /mnt/volume/media -name '*.nfo' -type f -size 0 -print0 | xargs -0 /bin/rm -f
# sanity check first to make sure we can access the content and parity files
if [ ! -e $CONTENT_FILE ]; then
echo "**ERROR** Content file ($CONTENT_FILE) not found!"
exit 1;
fi
if [ ! -e $PARITY_FILE ]; then
echo "**ERROR** Parity file ($PARITY_FILE) not found!"
exit 1;
fi
echo
echo "----------------------------------------"
echo "##Processing"
# Fix timestamps
chk_zero
# run the snapraid DIFF command
echo "###SnapRAID DIFF [`date`]"
$SNAPRAID_BIN diff
# wait for the above cmd to finish
wait
echo
echo "DIFF finished [`date`]"
JOBS_DONE="DIFF"
DEL_COUNT=$(grep -w '^ \{1,\}[0-9]* removed$' $TMP_OUTPUT | sed 's/^ *//g' | cut -d ' ' -f1)
ADD_COUNT=$(grep -w '^ \{1,\}[0-9]* added$' $TMP_OUTPUT | sed 's/^ *//g' | cut -d ' ' -f1)
MOVE_COUNT=$(grep -w '^ \{1,\}[0-9]* moved$' $TMP_OUTPUT | sed 's/^ *//g' | cut -d ' ' -f1)
COPY_COUNT=$(grep -w '^ \{1,\}[0-9]* copied$' $TMP_OUTPUT | sed 's/^ *//g' | cut -d ' ' -f1)
UPDATE_COUNT=$(grep -w '^ \{1,\}[0-9]* updated$' $TMP_OUTPUT | sed 's/^ *//g' | cut -d ' ' -f1)
# sanity check to make sure that we were able to get our counts from the output of the DIFF job
if [ -z "$DEL_COUNT" -o -z "$ADD_COUNT" -o -z "$MOVE_COUNT" -o -z "$COPY_COUNT" -o -z "$UPDATE_COUNT" ]; then
# failed to get one or more of the count values, lets report to user and exit with error code
echo "**ERROR** - failed to get one or more count values. Unable to proceed."
echo "Exiting script. [`date`]"
if [ $EMAIL_ADDRESS ]; then
SUBJECT="$EMAIL_SUBJECT_PREFIX WARNING - Unable to proceed with SYNC/SCRUB job(s). Check DIFF job output."
send_mail
fi
exit 1;
fi
echo
echo "**SUMMARY of changes - Added [$ADD_COUNT] - Deleted [$DEL_COUNT] - Moved [$MOVE_COUNT] - Copied [$COPY_COUNT] - Updated [$UPDATE_COUNT]**"
echo
# check if the conditions to run SYNC are met
# CHK 1 - if files have changed
if [ $DEL_COUNT -gt 0 -o $ADD_COUNT -gt 0 -o $MOVE_COUNT -gt 0 -o $COPY_COUNT -gt 0 -o $UPDATE_COUNT -gt 0 ]; then
chk_del
if [ $CHK_FAIL -eq 0 ]; then
chk_updated
fi
if [ $CHK_FAIL -eq 1 ]; then
chk_sync_warn
fi
else
# NO, so let's skip SYNC
echo "No change detected. Not running SYNC job. [`date`] "
DO_SYNC=0
fi
# Now run sync if conditions are met
if [ $DO_SYNC -eq 1 ]; then
echo "###SnapRAID SYNC [`date`]"
$SNAPRAID_BIN sync -q
#wait for the job to finish
wait
echo "SYNC finished [`date`]"
JOBS_DONE="$JOBS_DONE + SYNC"
# insert SYNC marker to 'Everything OK' or 'Nothing to do' string to differentiate it from SCRUB job later
sed_me "s/^Everything OK/SYNC_JOB--Everything OK/g;s/^Nothing to do/SYNC_JOB--Nothing to do/g" "$TMP_OUTPUT"
# Remove any warning flags if set previously. This is done in this step to take care of scenarios when user
# has manually synced or restored deleted files and we will have missed it in the checks above.
if [ -e $SYNC_WARN_FILE ]; then
rm $SYNC_WARN_FILE
fi
echo
echo "SnapRAID SCRUB *Newly Added*"
$SNAPRAID_BIN scrub -p new -q
wait
echo "SCRUB *Newly Added* finished [`date`]"
echo
fi
# Moving onto scrub now. Check if user has enabled scrub
if [ $SCRUB_PERCENT -gt 0 ]; then
# YES, first let's check if delete threshold has been breached and we have not forced a sync.
if [ $CHK_FAIL -eq 1 -a $DO_SYNC -eq 0 ]; then
# YES, parity is out of sync so let's not run scrub job
echo "Scrub job cancelled as parity info is out of sync (deleted or changed files threshold has been breached). [`date`]"
else
# NO, delete threshold has not been breached OR we forced a sync, but we have one last test -
# let's make sure if sync ran, it completed successfully (by checking for our marker text "SYNC_JOB--" in the output).
if [ $DO_SYNC -eq 1 -a -z "$(grep -w "SYNC_JOB-" $TMP_OUTPUT)" ]; then
# Sync ran but did not complete successfully so lets not run scrub to be safe
echo "**WARNING** - check output of SYNC job. Could not detect marker <SYNC_JOB-->. Not proceeding with SCRUB job. [`date`]"
else
# Everything ok - let's run the scrub job!
echo "###SnapRAID SCRUB [`date`]"
$SNAPRAID_BIN scrub -p $SCRUB_PERCENT -o $SCRUB_AGE -q
#wait for the job to finish
wait
echo "SCRUB finished [`date`]"
echo
JOBS_DONE="$JOBS_DONE + SCRUB"
# insert SCRUB marker to 'Everything OK' or 'Nothing to do' string to differentiate it from SYNC job above
sed_me "s/^Everything OK/SCRUB_JOB--Everything OK/g;s/^Nothing to do/SCRUB_JOB--Nothing to do/g" "$TMP_OUTPUT"
fi
fi
else
echo "Scrub job is not enabled. Not running SCRUB job. [`date`] "
fi
echo
echo "----------------------------------------"
echo "##Postprocessing"
# Moving onto logging SMART info if enabled
if [ $SMART_LOG -eq 1 ]; then
echo
$SNAPRAID_BIN smart
wait
fi
echo "Spinning down disks..."
$SNAPRAID_BIN down
# Graceful restore of services outside of trap - for messaging
GRACEFUL=1
restore_services
echo "All jobs ended. [`date`] "
# all jobs done, let's send output to user if configured
if [ $EMAIL_ADDRESS ]; then
echo -e "Email address is set. Sending email report to **$EMAIL_ADDRESS** [`date`]"
# check if deleted count exceeded threshold
if [ $CHK_FAIL -eq 1 ]; then
if [ $DEL_COUNT -gt $DEL_THRESHOLD -a $DO_SYNC -eq 0 ]; then
MSG="Deleted Files ($DEL_COUNT) / ($DEL_THRESHOLD) Violation"
fi
if [ $DEL_COUNT -gt $DEL_THRESHOLD -a $UPDATE_COUNT -gt $UP_THRESHOLD -a $DO_SYNC -eq 0 ]; then
MSG="$MSG & "
fi
if [ $UPDATE_COUNT -gt $UP_THRESHOLD -a $DO_SYNC -eq 0 ]; then
MSG="$MSG Changed Files ($UPDATE_COUNT) / ($UP_THRESHOLD) Violation"
fi
SUBJECT="[WARNING] $SYNC_WARN_COUNT - ($MSG) $EMAIL_SUBJECT_PREFIX"
elif [ -z "${JOBS_DONE##*"SYNC"*}" -a -z "$(grep -w "SYNC_JOB-" $TMP_OUTPUT)" ]; then
# Sync ran but did not complete successfully so lets warn the user
SUBJECT="[WARNING] SYNC job ran but did not complete successfully $EMAIL_SUBJECT_PREFIX"
elif [ -z "${JOBS_DONE##*"SCRUB"*}" -a -z "$(grep -w "SCRUB_JOB-" $TMP_OUTPUT)" ]; then
# Scrub ran but did not complete successfully so lets warn the user
SUBJECT="[WARNING] SCRUB job ran but did not complete successfully $EMAIL_SUBJECT_PREFIX"
else
SUBJECT="[COMPLETED] $JOBS_DONE Jobs $EMAIL_SUBJECT_PREFIX"
fi
ELAPSED="$(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
echo
echo "----------------------------------------"
echo "##Total time elapsed for SnapRAID: $ELAPSED"
# Add a topline to email body
sed_me "1s/^/##$SUBJECT \n/" "${TMP_OUTPUT}"
send_mail
fi
clean_desc
exit 0;
}
#######################
# FUNCTIONS & METHODS #
#######################
function sed_me(){
# The various redirects used force us to be a bit hands-on with sed
exec 1>&3 2>&4 3>&- 4>&-
$(sed -i "$1" "$2")
exec 3>&1 4>&2
exec > >(tee -ia "${TMP_OUTPUT}" ) 2>&1
wait
}
function chk_del(){
if [ $DEL_COUNT -lt $DEL_THRESHOLD ]; then
# NO, delete threshold not reached, lets run the sync job
echo "Changes detected [A-$ADD_COUNT,D-$DEL_COUNT,M-$MOVE_COUNT,C-$COPY_COUNT,U-$UPDATE_COUNT] and deleted files ($DEL_COUNT) is below threshold ($DEL_THRESHOLD). SYNC Authorized."
DO_SYNC=1
else
echo "**WARNING** Deleted files ($DEL_COUNT) exceeded threshold ($DEL_THRESHOLD)."
CHK_FAIL=1
fi
}
function chk_updated(){
if [ $UPDATE_COUNT -lt $UP_THRESHOLD ]; then
echo "Changes detected [A-$ADD_COUNT,D-$DEL_COUNT,M-$MOVE_COUNT,C-$COPY_COUNT,U-$UPDATE_COUNT] and updated files ($UPDATE_COUNT) is below threshold ($UP_THRESHOLD). SYNC Authorized."
DO_SYNC=1
else
echo "**WARNING** Updated files ($UPDATE_COUNT) exceeded threshold ($UP_THRESHOLD)."
CHK_FAIL=1
fi
}
function chk_sync_warn(){
if [ $SYNC_WARN_THRESHOLD -gt -1 ]; then
echo "Forced sync is enabled. [`date`]"
SYNC_WARN_COUNT=$(sed 'q;/^[0-9][0-9]*$/!d' $SYNC_WARN_FILE 2>/dev/null)
SYNC_WARN_COUNT=${SYNC_WARN_COUNT:-0} #value is zero if file does not exist or does not contain what we are expecting
if [ $SYNC_WARN_COUNT -ge $SYNC_WARN_THRESHOLD ]; then
# YES, lets force a sync job. Do not need to remove warning marker here as it is automatically removed when the sync job is run by this script
echo "Number of warning(s) ($SYNC_WARN_COUNT) has reached/exceeded threshold ($SYNC_WARN_THRESHOLD). Forcing a SYNC job to run. [`date`]"
DO_SYNC=1
else
# NO, so let's increment the warning count and skip the sync job
((SYNC_WARN_COUNT += 1))
echo $SYNC_WARN_COUNT > $SYNC_WARN_FILE
echo "$((SYNC_WARN_THRESHOLD - SYNC_WARN_COUNT)) warning(s) till forced sync. NOT proceeding with SYNC job. [`date`]"
DO_SYNC=0
fi
else
# NO, so let's skip SYNC
echo "Forced sync is not enabled. Check $TMP_OUTPUT for details. NOT proceeding with SYNC job. [`date`]"
DO_SYNC=0
fi
}
function chk_zero(){
echo "###SnapRAID TOUCH [`date`]"
echo "Checking for zero sub-second files."
TIMESTATUS=$($SNAPRAID_BIN status | grep 'You have [1-9][0-9]* files with zero sub-second timestamp\.' | sed 's/^You have/Found/g')
if [ -n "$TIMESTATUS" ]; then
echo "$TIMESTATUS"
echo "Running TOUCH job to timestamp. [`date`]"
$SNAPRAID_BIN touch
wait
echo "TOUCH finished [`date`]"
else
echo "No zero sub-second timestamp files found."
fi
}
function stop_services(){
# Disable Sophos on-access
if /opt/sophos-av/bin/savdstatus | grep -v "not running" > /dev/null; then
echo "Sophos on-access detected, shutting it down..."
/opt/sophos-av/bin/savdctl disable
wait
SOPHOS_RUNNING=1
fi
# Systemctl example
# Be sure to add an associated SERVICE_A_RUNNING=0 INIT VARIABLES above
#if [ `systemctl is-active service-A.service` == "active" ]; then
# echo "SERVICE_A detected, shutting it down..."
# systemctl stop service-A.service
# SERVICE_A_RUNNING=1
#fi
}
function restore_services(){
echo
# Enable Sophos on-access scanning
if [ $SOPHOS_RUNNING -eq 1 ]; then
echo "Restoring Sohpos on-access to active state..."
/opt/sophos-av/bin/savdctl enable
wait
SOPHOS_RUNNING=0
fi
# Systemctl example
#if [ $SERVICE_A_RUNNING -eq 1 ]; then
# systemctl start service-A.service
# echo "Restoring SERVICE_A to active state..."
# SERVICE_A_RUNNING=0
#fi
if [ $GRACEFUL -eq 1 ]; then
return
fi
clean_desc
exit
}
function clean_desc(){
# Cleanup file descriptors
exec 1>&3 2>&4
# If interactive shell restore output
[[ $- == *i* ]] && exec &>/dev/tty
}
function send_mail(){
# Format for markdown
sed_me "s/$/ /" "$TMP_OUTPUT"
$MAIL_BIN -a 'Content-Type: text/html' -s "$SUBJECT" "$EMAIL_ADDRESS" < <(python -m markdown $TMP_OUTPUT)
}
# Set TRAP
trap restore_services INT EXIT
main "$@"
@cannondale0815

This comment has been minimized.

Copy link

cannondale0815 commented Apr 22, 2017

EDIT: I helped myself by installing 'bsd-mailx' on my Ubuntu 16.04 system and then configuring this script to use that instead. The 'regular' mailx didn't understand the '-a' parameter as 'append-header', but instead interprets it as 'attach file'.


Hey there, I was previously using Zack's script but thought to give this a try. I am getting the following error when it's trying to send an email (I do have python-markdown installed). This is on Ubuntu 16.04:

##Total time elapsed for SnapRAID: 1hrs 8min 41sec
Content-Type: text/html: No such file or directory

Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/dist-packages/markdown/main.py", line 136, in
run()
File "/usr/lib/python2.7/dist-packages/markdown/main.py", line 130, in run
markdown.markdownFromFile(**options)
File "/usr/lib/python2.7/dist-packages/markdown/init.py", line 529, in markdownFromFile
kwargs.get('encoding', None))
File "/usr/lib/python2.7/dist-packages/markdown/init.py", line 464, in convertFile
sys.stdout.write(html)
IOError: [Errno 32] Broken pipe

@tehniemer

This comment has been minimized.

Copy link

tehniemer commented Aug 10, 2019

Question about emails, is no message in the body of the email expected?

All jobs ended. [Sat Aug 10 13:13:12 CDT 2019]
Email address is set. Sending email report to **someemail@gmail.com** [Sat Aug 10 13:13:12 CDT 2019]

----------------------------------------
##Total time elapsed for SnapRAID: 1hrs 0min 40sec
/usr/bin/python: No module named markdown

root@openmediavault:~# Null message body; hope that's ok
@mtompkins

This comment has been minimized.

Copy link
Owner Author

mtompkins commented Aug 10, 2019

It should send an email, but in truth, I haven't looked at this in quite some time.

Yours is indicating you don't have python's markdown installed it seems.

@tehniemer

This comment has been minimized.

Copy link

tehniemer commented Aug 12, 2019

Thanks, I installed markdown and it's populating the body of the message now.

@tehniemer

This comment has been minimized.

Copy link

tehniemer commented Aug 23, 2019

Now that I have emails working I'm seeing this message

Preprocessing
Stop Services [Fri Aug 23 06:12:20 CDT 2019]

/root/snapScript.sh: line 378: /opt/sophos-av/bin/savdstatus: No such file or directory
Remove Zero Byte NFOs [Fri Aug 23 06:12:20 CDT 2019]

Removing any 0 byte .nfo's before SnapRAID exeuction.
find: ‘/mnt/volume/media’: No such file or directory 

Can you shed some light on what these two are supposed to be doing? Would it be possible to add in a master enable/disable bit for these functions if they are not critical to function?

@gderf

This comment has been minimized.

Copy link

gderf commented Dec 13, 2019

Script had been running fine for years on various versions of Debian. But now on v10 Buster the script hangs after running the diff part. Final output is:

103105 equal
101 added
1 removed
43 updated
1 moved
0 copied
0 restored
There are differences!

(hangs at this point)

@auanasgheps

This comment has been minimized.

Copy link

auanasgheps commented Dec 14, 2019

Script hangs on Debian 10 for me too.

@mtompkins

This comment has been minimized.

Copy link
Owner Author

mtompkins commented Dec 18, 2019

There has been a subtle change in how the wait instruction is handled in BASH.
If you remove them all from the script, you'll likely resolve your issues. They were always a bit spurious.

@gderf

This comment has been minimized.

Copy link

gderf commented Dec 18, 2019

Thanks for looking into this. The suggestion to remove the wait instructions worked.

@auanasgheps

This comment has been minimized.

Copy link

auanasgheps commented Jan 8, 2020

Have removed the wait and can run the script, but looks like it hangs at the end like this and does not close, I have to force it.

immagine

@gderf

This comment has been minimized.

Copy link

gderf commented Jan 8, 2020

I am also seeing this hang. What I have been able to determine is that in my case htop shows that it is gaining a lot of time and never ends when executing this:

python -m markdown /tmp/snapRAID.out

At the time that particular snapRAID.out file was about 15MB.

The email is not received.

Removing the waits solved the last problem and the script ran fine for weeks until today.

@auanasgheps

This comment has been minimized.

Copy link

auanasgheps commented Jan 9, 2020

hoping @mtompkins can advise

@gderf

This comment has been minimized.

Copy link

gderf commented Jan 9, 2020

Ran fine for me today.

@mtompkins

This comment has been minimized.

Copy link
Owner Author

mtompkins commented Jan 13, 2020

Sounds like there is some anomaly with the python module that converts the markdown to HTML for mailing.
It sounds like you may need to investigate a possible alternate way of converting the job log which is markdown "friendly" to HTML.

@gderf

This comment has been minimized.

Copy link

gderf commented Jan 15, 2020

Noticed a bug to day.

I run the script on cron every other day at 3:00am. However, I had the need to run it manually yesterday. The manual run was still running when cron triggered the scheduled run. The result is that snapraid detected its own lock file, refused to run, and this was noted in the /tmp/snapRAID.out file. However, the already existing snapRAID.out file was erased and a new one created by the second instance of the script, causing the already existing material in the file to be lost.

Perhaps it would be better to check for the existence of a snapRAID.out file before overwriting it?

@mtompkins

This comment has been minimized.

Copy link
Owner Author

mtompkins commented Jan 15, 2020

@gderf I think that's a very reasonable assessment, thank you. For my own needs, I don't use the script for manual invocation so it isn't something I'll adjust - but I agree that such a change might be useful to others.

FWIW, I use aliases for manual invocations in a screen session as follows:

function rmZeroNFO() {
        echo "----- [`date`] Begin removal of zero length .nfo files -----"
        #find /mnt/volume/media -name '*.nfo' -type f -size 0 -print0 | xargs -0 /bin/rm -f
        #find /mnt/volume/media -name '*.nfo' -type f -size 0 -delete
        find /mnt/volume/media -name '*.nfo' -type f -size 0 -exec echo "Removing: "{} \; -exec /bin/rm -f {} \;
        echo "----- [`date`] End removal of zero length .nfo files -----"
}
function snapSYNC() {

        LOGFILE=/var/log/snapraid/snapSYNC.log

        exec &> >(tee -ia "${LOGFILE}")

        #sophosOFF
        snapraid up
        rmZeroNFO
        echo "----- [`date`] Begin snapraid touch -----"
        ionice -c 3 snapraid touch
        echo "----- [`date`] End snapraid touch -----"
        echo "----- [`date`] Begin snapraid sync -----"
        ionice -c 3 snapraid sync
        echo "----- [`date`] End snapraid sync -----"
        echo "----- [`date`] Begin snapraid scrub -----"
        ionice -c 3 snapraid scrub -p new
        echo "----- [`date`] End snapraid scrub -----"
        echo
        #sophosON

        exec &>/dev/tty
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.