Added exclude function
This commit is contained in:
+16
-13
@@ -1,25 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
#----------------- User Variables, Please adjust in Master.cong as needed ----------------------
|
#----------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
# This is the main Core Rsync script
|
# This is the main Core Rsync script
|
||||||
#
|
#
|
||||||
# User vaiables can be adjusted in Master.conf
|
# User variables can be adjusted in Master.conf
|
||||||
# scripts now just contain runtime codes
|
# Scripts now just contain runtime logic
|
||||||
#
|
#
|
||||||
# This allows for profiles and multiple things to use the core script
|
# This allows for profiles and multiple things to use the core script
|
||||||
# use arguments in unRAID User Plugin for directory
|
# Use arguments in unRAID User Plugin for directory
|
||||||
# Example = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh
|
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/
|
||||||
# /mnt/user/appdata-test/Arrs/
|
|
||||||
#
|
#
|
||||||
# /mnt/user/appdata-test/Arrs/ is the argument
|
# /mnt/user/appdata-test/Arrs/ is the argument
|
||||||
# If the last name /Arrs/ matches a profile in Master.conf then profiles are used
|
# If the last name /Arrs/ matches a profile in Master.conf, then profile defaults are used
|
||||||
# If no matches then Global Configureation is used in Master.conf
|
# Otherwise, global configuration in Master.conf is used
|
||||||
#
|
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
#---------------End Of User Variables, Please adjust in Master.cong as needed ------------------
|
#---------------End Of User Variables ----------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Detect script directory
|
# Detect script directory
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
@@ -74,9 +73,9 @@ DELAYED_CONTAINERS=(${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]})
|
|||||||
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
||||||
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
||||||
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
||||||
EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]})
|
EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-${EXCLUDE_DIRS[@]}})
|
||||||
|
|
||||||
echo "Settings: MAX_RSYNC_PROCS=$MAX_RSYNC_PROCS, BW_LIMIT=$BW_LIMIT, CONTAINERS=${CRITICAL_CONTAINER_NAMES[*]}"
|
echo "Settings: MAX_RSYNC_PROCS=$MAX_RSYNC_PROCS, BW_LIMIT=$BW_LIMIT, CONTAINERS=${CRITICAL_CONTAINER_NAMES[*]}, EXCLUDES=${EXCLUDE_DIRS[*]}"
|
||||||
|
|
||||||
# Dependency check
|
# Dependency check
|
||||||
for cmd in rsync ssh ping timeout docker tailscale; do
|
for cmd in rsync ssh ping timeout docker tailscale; do
|
||||||
@@ -134,7 +133,6 @@ start_containers() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Main sync logic
|
# Main sync logic
|
||||||
main() {
|
main() {
|
||||||
echo "[$LOCAL_SERVER_NAME] Syncing $DIRECTORY → $REMOTE_SERVER:$DIRECTORY"
|
echo "[$LOCAL_SERVER_NAME] Syncing $DIRECTORY → $REMOTE_SERVER:$DIRECTORY"
|
||||||
@@ -162,6 +160,11 @@ main() {
|
|||||||
--no-whole-file
|
--no-whole-file
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Apply profile-specific excludes
|
||||||
|
for ex in "${EXCLUDE_DIRS[@]}"; do
|
||||||
|
RSYNC_OPTS+=(--exclude="$ex")
|
||||||
|
done
|
||||||
|
|
||||||
[ "$DRY_RUN" = true ] && RSYNC_OPTS+=("--dry-run")
|
[ "$DRY_RUN" = true ] && RSYNC_OPTS+=("--dry-run")
|
||||||
|
|
||||||
for attempt in $(seq 1 "$RETRY_COUNT"); do
|
for attempt in $(seq 1 "$RETRY_COUNT"); do
|
||||||
|
|||||||
Reference in New Issue
Block a user