Browse Source

wrapper_run_task.sh now works for both backup and maintenance tasks [=[=

Wazakindjes 2 months ago
parent
commit
29992a6335
1 changed files with 18 additions and 6 deletions
  1. 18 6
      skrip/wrapper_run_task.sh

+ 18 - 6
skrip/wrapper_run_task.sh

@@ -4,7 +4,7 @@ wrapname=$(basename "$0")
 
 if [[ -z $2 ]] || [[ $1 =~ ^-*h[ae]lp$ ]]; then
 	echo "Usage: $wrapname <component name (e.g. mysql)> <max wait time in seconds> [log directory, <max log size>]"
-	echo "The wait time is to prevent multiple backups from running at 0nce, you'll pr0lly want to set it to an hour or so ;]"
+	echo "The wait time is to prevent multiple backup/maintenance tasks from running at 0nce ;]"
 	echo "The minimum is 10 seconds cuz we'll wait approximately that long between each check"
 	echo "Alternatively, set it to 0 to wait indefinitely"
 	echo ''
@@ -21,9 +21,21 @@ maxlogsize="$4"
 logpath=''
 loggem=false
 
+if [[ $component == 'maintenance' ]]; then
+	maintenance=true
+else
+	maintenance=false
+fi
+
 cpath_root=$(realpath "$SKRIPDIR/../components")
 cpath=$(realpath "$cpath_root/$component")
-runpath="$cpath/run_backup_all.sh"
+
+if $maintenance; then
+	runfile='run_maintenance_all.sh'
+else
+	runfile='run_backup_all.sh'
+fi
+runpath="$cpath/$runfile"
 
 tempdir='/tmp'
 pidfile="$tempdir/muhbackup_wrapper_$component.pid"
@@ -40,7 +52,7 @@ if [[ ! -d $cpath ]]; then
 fi
 
 if [[ ! -f $runpath || ! -x $runpath ]]; then
-	echo "Component doesn't contain a script 'run_backup_all.sh', or it's not executable: $runpath"
+	echo "Component doesn't contain a script '$runfile', or it's not executable: $runpath"
 	exit 3
 fi
 
@@ -93,7 +105,7 @@ echo $muhpid > $pidfile
 # Let's also maek sure we don't run when a ZFS scrub is in br0gress =]]
 #if [[ ! -z $(which zpool) ]]; then
 #	if zpool status 2>&1 | grep -qF 'scrub in progress'; then
-#		echo "[ERROR] We better not run backups when a ZFS scrub is in br0gress ;];]"
+#		echo "[ERROR] We better not run any tasks when a ZFS scrub is in br0gress ;];]"
 #		rm -vf "$pidfile"
 #		exit 1
 #	fi
@@ -118,9 +130,9 @@ endtime=$((`date +%s` + $maxwait))
 doit=false
 ticks=0
 
-echo -n "Waiting for other running backups"
+echo -n "Waiting for other running tasks"
 while true; do
-	checkem=$(ps axww | grep -F "$cpath_root" | grep -F "run_backup_all.sh" | grep -v "grep .*$cpath_root")
+	checkem=$(ps axww | grep -F "$cpath_root" | grep -E "run_(backup|maintenance)_all.sh" | grep -v "grep .*$cpath_root")
 	if [[ -z $checkem ]]; then
 		doit=true
 		break