This commit is contained in:
2026-03-21 21:34:42 +00:00
parent 546686ac8c
commit a932232da7
5 changed files with 121 additions and 18 deletions
+10 -15
View File
@@ -4,13 +4,12 @@
##################################################################################################
#-----------------------------------------------------------------------------------------------
#----------------------------- Host Detection ---------------------------------------------------
#----------------------------- Host and Remote Detection ---------------------------------------
#-----------------------------------------------------------------------------------------------
# Define the hostnames of both servers
HOST1="unRAID-Gmer4Lfe"
HOST2="unRAID-Jayred365"
# Detect local hostname
LOCAL_HOSTNAME="$(hostname)"
if [[ "$LOCAL_HOSTNAME" == "$HOST1" ]]; then
@@ -27,7 +26,7 @@ echo "Local server: $LOCAL_SERVER_NAME"
echo "Remote server: $REMOTE_SERVER_NAME"
#-----------------------------------------------------------------------------------------------
#----------------------------- Remote Server Resolution -----------------------------------------
#--------------------------- Remote Server Ip Resolution ----------------------------------------
#-----------------------------------------------------------------------------------------------
# Resolve Tailscale IP dynamically
REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null)
@@ -78,19 +77,15 @@ CONTAINER_DELAY=5
#-----------------------------------------------------------------------------------------------
# Profiles are inferred from the directory basename (lowercased)
#-----------------------------------------------------------------------------------------------
#----------------------------- Profile Performance Tuning ---------------------------------------
#-----------------------------------------------------------------------------------------------
# Max rsync processes per profile
declare -A PROFILE_MAX_PROCS
PROFILE_MAX_PROCS["arrs_stack"]=2
PROFILE_MAX_PROCS["movies"]=1
PROFILE_MAX_PROCS["critical-data"]=2
PROFILE_MAX_PROCS["shows"]=1
# Bandwidth limits per profile (KB/s, 0 = unlimited)
declare -A PROFILE_BW_LIMIT
PROFILE_BW_LIMIT["arrs_stack"]=5000
PROFILE_BW_LIMIT["movies"]=0
PROFILE_BW_LIMIT["critical-data"]=9500
PROFILE_BW_LIMIT["shows"]=8000
# Retry logic per profile
declare -A PROFILE_RETRY_COUNT
@@ -100,22 +95,22 @@ PROFILE_RETRY_COUNT["shows"]=3
# Sleep between retries per profile (seconds)
declare -A PROFILE_SLEEP
PROFILE_SLEEP["arrs_stack"]=300
PROFILE_SLEEP["movies"]=300
PROFILE_SLEEP["critical-data"]=300
PROFILE_SLEEP["shows"]=300
# Containers to stop/start per profile (space-separated strings)
declare -A PROFILE_CRITICAL_CONTAINER_NAMES
PROFILE_CRITICAL_CONTAINER_NAMES["arrs_stack"]="Sonarr Lidarr Readarr Radarr Prowlarr Bazarr Pinchflat"
PROFILE_CRITICAL_CONTAINER_NAMES["movies"]=""
PROFILE_CRITICAL_CONTAINER_NAMES["critical-data"]=""
PROFILE_CRITICAL_CONTAINER_NAMES["shows"]=""
# Delayed containers per profile (space-separated strings)
declare -A PROFILE_DELAYED_CONTAINERS
PROFILE_DELAYED_CONTAINERS["arrs_stack"]=""
PROFILE_DELAYED_CONTAINERS["movies"]=""
PROFILE_DELAYED_CONTAINERS["arrs_stack"]="Mariadb-Authelia Redis-Authelia Lldap-Gmer4Lfe NginxProxyManager Authelia"
PROFILE_DELAYED_CONTAINERS["critical-data"]="Authelia"
PROFILE_DELAYED_CONTAINERS["shows"]=""
# Delay in seconds before starting delayed containers per profile
# Delay in seconds before starting delayed containers per profile (seconds)
declare -A PROFILE_CONTAINER_DELAY
PROFILE_CONTAINER_DELAY["arrs_stack"]=5
PROFILE_CONTAINER_DELAY["movies"]=0
PROFILE_CONTAINER_DELAY["critical-data"]=10
PROFILE_CONTAINER_DELAY["shows"]=0
#-----------------------------------------------------------------------------------------------
+18
View File
@@ -0,0 +1,18 @@
This is the Rsync Setup Guide
This guide is a work in progress
First git Repository need installed at /mnt/user/appdata/unraid_scripts/
Then made executable, copy and paste contents of git_pull_execute.sh script to a new script in unRAID User Scripts
in unRAID User Scripts, to use scripts in git
Create a new Script and name it whatever
You can copy contents of user_script_pluin.sh and paste then change acordingly
or
add a line pointing to script plus local folder to be synced
Exampl = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/
This opens the script and passes the folder overas an argument
This allows for multiple rsync ops running off a single core script
All changes made to 1 single core script then works for all user scripts that point to rsync.sh
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
set -e
# -----------------------------
# Configurable variables
# -----------------------------
REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git"
TARGET_DIR="/mnt/user/appdata/unraid_scripts"
SSH_KEY="/root/.ssh/id_gitea_rsync"
SSH_PORT=221
# -----------------------------
# Create target directory if it doesn't exist
# -----------------------------
mkdir -p "$TARGET_DIR"
cd "$TARGET_DIR"
# -----------------------------
# Clone or pull repo (discard local changes)
# -----------------------------
if [ -d ".git" ]; then
echo "Repository already exists. Resetting local changes and pulling latest..."
git reset --hard
git clean -fd
GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git pull
else
echo "Cloning $REPO_SSH into $TARGET_DIR..."
GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git clone "$REPO_SSH" .
fi
# -----------------------------
# Ensure scripts are executable
# -----------------------------
echo "Setting executable permissions on scripts..."
find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \;
echo "Repository is up to date and scripts are executable."
+4 -3
View File
@@ -3,6 +3,7 @@ set -e
#-----------------------------------------------------------------------------------------------
#----------------- User Variables, Please adjust in Master.cong as needed ----------------------
#-----------------------------------------------------------------------------------------------
# This is the main Core Rsync script
#
# User vaiables can be adjusted in Master.conf
# scripts now just contain runtime codes
@@ -10,10 +11,10 @@ set -e
# This allows for profiles and multiple things to use the core script
# use arguments in unRAID User Plugin for directory
# Example = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh
# /mnt/user/appdata-Failover/Arrs_Stack/
# /mnt/user/appdata-test/Arrs/
#
# /mnt/user/appdata-Failover/Arrs_Stack/ is the argument
# If the last name /Arrs-Stack/ matches a profile in Master.conf then profiles are used
# /mnt/user/appdata-test/Arrs/ is the argument
# If the last name /Arrs/ matches a profile in Master.conf then profiles are used
# If no matches then Global Configureation is used in Master.conf
#
#-----------------------------------------------------------------------------------------------
+52
View File
@@ -0,0 +1,52 @@
!/bin/bash
#-----------------------------------------------------------------------------------------------
#------------------------------------- Rsync command -------------------------------------------
#-----------------------------------------------------------------------------------------------
/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/
#-----------------------------------------------------------------------------------------------
#-------------------------------------------- Info ---------------------------------------------
#-----------------------------------------------------------------------------------------------
#
# These global configuartions can be added as arguments at the end of the script after folder location
# Its better to add profile in Master.conf for perm changes
# Profiles in Master.conf match the last string of folder location
# if a match is made with a list in Master.conf then the associated profile will be used
# If no match is made it defualts to global defualts
#
#-----------------------------------------------------------------------------------------------
#----------------- User Variables, Please adjust in Master.cong as needed ----------------------
#-----------------------------------------------------------------------------------------------
#
# Does a dry run making no changes
#--dry-run
#
# 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
#DELAYED_CONTAINERS=()
#
# Delay in seconds between starting containers, useful for things like Authelia
#CONTAINER_DELAY=5
#
#-----------------------------------------------------------------------------------------------
#---------------End Of User Variables, Please adjust in Master.cong as needed ------------------
#-----------------------------------------------------------------------------------------------
#
#Examples
#/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ MAX_RSYNC_PROCS=2
#/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ --dry-run MAX_RSYNC_PROCS=2