Changed daily script to master.conf variables
This commit is contained in:
+21
-12
@@ -22,16 +22,12 @@ SSH_KEY="/root/.ssh/id_gitea_rsync"
|
||||
SSH_PORT=221
|
||||
|
||||
# -------------------Rsync Script Defaults-----------------------
|
||||
# turns on or off progress info for rsync
|
||||
ENABLE_PROGRESS=true
|
||||
# Network speed limit (KB/s)
|
||||
BW_LIMIT=12500
|
||||
# Retry logic
|
||||
RETRY_COUNT=3
|
||||
# Sleep between retries (seconds)
|
||||
SLEEP=300
|
||||
# Max number of concurrently running rsync processes
|
||||
MAX_RSYNC_PROCS=1
|
||||
# Container start/stop/restart before and after rsync
|
||||
CRITICAL_CONTAINER_NAMES=()
|
||||
# Containers that need delayed before starting
|
||||
@@ -43,6 +39,25 @@ SSH_PORT=221
|
||||
# Default global rsync options
|
||||
DEFAULT_RSYNC_OPTS=(-av --info=progress2 --human-readable --bwlimit="$BW_LIMIT" --delete --inplace --no-whole-file)
|
||||
|
||||
# ------------------- Daily Sync Shares -------------------------
|
||||
# Shares synced once daily by Orchestrators/daily_sync.sh
|
||||
# Add or remove paths here to manage what gets synced
|
||||
DAILY_SYNC_SHARES=(
|
||||
/mnt/user/Anime_Movies-Old
|
||||
/mnt/user/Anime_Shows-Old
|
||||
/mnt/user/Anime_Shows
|
||||
/mnt/user/Books
|
||||
/mnt/user/Intros
|
||||
/mnt/user/Kids_Movies
|
||||
/mnt/user/Kids_Tv_Shows
|
||||
/mnt/user/Movies
|
||||
/mnt/user/Music_Videos
|
||||
/mnt/user/Nextcloud
|
||||
/mnt/user/stand-up_comedy
|
||||
/mnt/user/Tv_Shows
|
||||
/mnt/user/appdata-Failover/Gmer4Lfe/
|
||||
)
|
||||
|
||||
# ------------------- unRAID essentail scripts ------------------
|
||||
# unRAID reboot script user warning time (seconds)
|
||||
REBOOT_SLEEP=300
|
||||
@@ -58,6 +73,7 @@ SSH_PORT=221
|
||||
# --------------------- Profile System -------------------------
|
||||
# Profiles are inferred from the directory basename (lowercased)
|
||||
# Profile-specific rsync options (override global) must list all options as they do not inherit from global
|
||||
# Shares with no profile entry fall through to DEFAULT_RSYNC_OPTS above
|
||||
|
||||
# SPACE-SEPARATED STRINGS
|
||||
declare -A PROFILE_RSYNC_OPTS=(
|
||||
@@ -68,14 +84,6 @@ declare -A PROFILE_RSYNC_OPTS=(
|
||||
[emby]="-av --human-readable --bwlimit=$BW_LIMIT"
|
||||
)
|
||||
|
||||
declare -A PROFILE_MAX_PROCS=(
|
||||
[arrs_stack]=2
|
||||
[critical-data]=2
|
||||
[gmer4lfe]=1
|
||||
[important-data]=2
|
||||
[emby]=1
|
||||
)
|
||||
|
||||
declare -A PROFILE_BW_LIMIT=(
|
||||
[arrs_stack]=5000
|
||||
[critical-data]=9500
|
||||
@@ -137,3 +145,4 @@ declare -A PROFILE_EXCLUDE_DIRS=(
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
#---------------------- End Of User Variables, Please adjust above as needed -------------------
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Runs all bulk media shares sequentially. Scheduled via unRAID User Scripts plugin at 1am.
|
||||
# Per-share rsync handled by rsync.sh — this script tracks pass/fail and total time only.
|
||||
# Add or remove shares in Master.conf under DAILY_SYNC_SHARES.
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -13,21 +14,6 @@ source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
RSYNC_SCRIPT="$SCRIPT_DIR/../Rsync/rsync.sh"
|
||||
|
||||
SHARES=(
|
||||
/mnt/user/Anime_Movies-Old
|
||||
/mnt/user/Anime_Shows-Old
|
||||
/mnt/user/Anime_Shows
|
||||
/mnt/user/Books
|
||||
/mnt/user/Intros
|
||||
/mnt/user/Kids_Movies
|
||||
/mnt/user/Kids_Tv_Shows
|
||||
/mnt/user/Movies
|
||||
/mnt/user/Music_Videos
|
||||
/mnt/user/Nextcloud
|
||||
/mnt/user/stand-up_comedy
|
||||
/mnt/user/Tv_Shows
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Duration Formatter
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
@@ -51,10 +37,10 @@ TOTAL_START=$(date +%s)
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
echo ""
|
||||
echo "$ICON_SYNC Daily Sync Starting — $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
echo "Shares: ${#SHARES[@]}"
|
||||
echo "Shares: ${#DAILY_SYNC_SHARES[@]}"
|
||||
echo ""
|
||||
|
||||
for SHARE in "${SHARES[@]}"; do
|
||||
for SHARE in "${DAILY_SYNC_SHARES[@]}"; do
|
||||
SHARE_NAME=$(basename "$SHARE")
|
||||
SHARE_START=$(date +%s)
|
||||
|
||||
@@ -96,8 +82,8 @@ for entry in "${SHARE_TIMES[@]}"; do
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
echo " Passed: ${#PASS[@]}/${#SHARES[@]}"
|
||||
echo " Failed: ${#FAIL[@]}/${#SHARES[@]}"
|
||||
echo " Passed: ${#PASS[@]}/${#DAILY_SYNC_SHARES[@]}"
|
||||
echo " Failed: ${#FAIL[@]}/${#DAILY_SYNC_SHARES[@]}"
|
||||
echo " Duration: $(format_duration $TOTAL_DURATION)"
|
||||
echo "=============================="
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
||||
info "Profile: $PROFILE_NAME"
|
||||
|
||||
# Scalar overrides from profile
|
||||
MAX_RSYNC_PROCS=${PROFILE_MAX_PROCS[$PROFILE_NAME]:-$MAX_RSYNC_PROCS}
|
||||
BW_LIMIT=${PROFILE_BW_LIMIT[$PROFILE_NAME]:-$BW_LIMIT}
|
||||
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
||||
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
||||
@@ -47,8 +46,6 @@ CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
||||
read -r -a CRITICAL_CONTAINER_NAMES <<< "${PROFILE_CRITICAL_CONTAINER_NAMES[$PROFILE_NAME]:-}"
|
||||
read -r -a DELAYED_CONTAINERS <<< "${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]:-}"
|
||||
read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-}"
|
||||
echo "DEBUG containers array size: ${#CRITICAL_CONTAINER_NAMES[@]}"
|
||||
echo "DEBUG containers content: ${CRITICAL_CONTAINER_NAMES[*]}"
|
||||
|
||||
[[ "$SHOW_STATUS" == true ]] && show_status && exit 0
|
||||
|
||||
@@ -62,8 +59,6 @@ echo "Remote: $REMOTE_SERVER:$DIRECTORY"
|
||||
echo "Profile: $PROFILE_NAME"
|
||||
echo ""
|
||||
|
||||
wait_for_rsync
|
||||
|
||||
stop_containers
|
||||
|
||||
get_rsync_opts
|
||||
|
||||
@@ -191,30 +191,6 @@ start_containers() {
|
||||
done
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# RSYNC SLOT LIMITER
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
wait_for_rsync() {
|
||||
: "${RETRY_COUNT:=5}"
|
||||
: "${MAX_RSYNC_PROCS:=2}"
|
||||
: "${SLEEP:=2}"
|
||||
|
||||
for i in $(seq 1 "$RETRY_COUNT"); do
|
||||
COUNT=$(ps -eo cmd | grep "[r]sync .*${REMOTE_SERVER}" | wc -l || true)
|
||||
|
||||
if [[ "$COUNT" -ge "$MAX_RSYNC_PROCS" ]]; then
|
||||
warn "$ICON_RETRY Waiting for rsync slot ($COUNT/$MAX_RSYNC_PROCS) — attempt $i/$RETRY_COUNT"
|
||||
sleep "$SLEEP"
|
||||
else
|
||||
log "Rsync slot available ($COUNT/$MAX_RSYNC_PROCS)"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
error "Too many rsync processes after $RETRY_COUNT attempts, aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# RSYNC OPTIONS
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user