January 13Jan 13 Hi,i have written a backup script to backup at a regular interval, using the User Scripts plugin, selected folders on my shares to an external HDD conencted via USB to my unraid server; this external HDD is mounted as Unassigned Device.When i manually run the script, it seems to be working initially as it is copying using rsync, but the copying (i.e. rsync) seems to get stuck at a certain point when copying my photos; i see following errors in the log that is written to the external hard drive:rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(716) [sender=3.4.1]rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(519) [generator=3.4.1]files are being copied, i cna see them on my external hard drive, but just until the point that the above rsync errors are thrown.I don't understand these rsync errors, can someone explain what is happening and how to solve them please?Below my script in case anyone is interested:#!/bin/bashSOURCE_BASE="/mnt/user"DEST_BASE="/mnt/disks/External_HDD_1TB"ERROR_FOUND=0# --- MOUNTING ---# Check if already mounted; if not, try to mount itif [ ! -d "$DEST_BASE" ]; then echo "Attempting to mount $DEST_BASE ..." /usr/local/sbin/rc.unassigned mount "$DEST_BASE" sleep 5 # Give it a few seconds to initializefi# Now we define log paths after the mount attemptLOG_DIR="$DEST_BASE/logs"DATE=$(date +%Y-%m-%d_%H-%M)LOG_FILE="$LOG_DIR/backup_$DATE.log"# --- EXECUTION ---if [ -d "$DEST_BASE" ]; then #send notification in dashboard /usr/local/emhttp/webGui/scripts/notify -i normal -s "Backup to External HDD" -d "Backup STARTED" # Create log directory if it doesn't exist mkdir -p "$LOG_DIR" echo "--- Backup Log for $DATE ---" > "$LOG_FILE" # Run rsync #photo/Albums echo "Syncing photo/Albums..." >> "$LOG_FILE" mkdir -p "$DEST_BASE/data/media/photo/Albums/" rsync -avX --delete --stats "$SOURCE_BASE/data/media/photo/Albums/" "$DEST_BASE/data/media/photo/Albums/" >> "$LOG_FILE" 2>&1 if [ $? -eq 0 ]; then echo "photo/Albums sync successful." >> "$LOG_FILE" else echo "ERROR: photo/Albums sync failed!" >> "$LOG_FILE" ERROR_FOUND=1 fi echo "----------------------------" >> "$LOG_FILE" #photo/Immich/library # --- 1. STOP CONTAINERS --- echo "Stopping Immich for safety..." >> "$LOG_FILE" docker stop immich sleep 5 # --- 2. RUN THE SYNC --- echo "Syncing photo/Immich/library..." >> "$LOG_FILE" mkdir -p "$DEST_BASE/data/media/photo/Immich/library/" rsync -avX --delete --stats "$SOURCE_BASE/data/media/photo/Immich/library/" "$DEST_BASE/data/media/photo/Immich/library/" >> "$LOG_FILE" 2>&1 if [ $? -eq 0 ]; then echo "photo/Immich/library sync successful." >> "$LOG_FILE" else echo "ERROR: photo/Immich/library sync failed!" >> "$LOG_FILE" ERROR_FOUND=1 fi echo "----------------------------" >> "$LOG_FILE" # --- 3. START CONTAINERS --- echo "Restarting Immich..." >> "$LOG_FILE" docker start immich #music echo "Syncing music..." >> "$LOG_FILE" mkdir -p "$DEST_BASE/data/media/music/" rsync -avX --delete --stats "$SOURCE_BASE/data/media/music/" "$DEST_BASE/data/media/music/" >> "$LOG_FILE" 2>&1 if [ $? -eq 0 ]; then echo "music sync successful." >> "$LOG_FILE" else echo "ERROR: music sync failed!" >> "$LOG_FILE" ERROR_FOUND=1 fi echo "----------------------------" >> "$LOG_FILE" #documents echo "Syncing documents..." >> "$LOG_FILE" mkdir -p "$DEST_BASE/data/documents/" rsync -avX --delete --stats "$SOURCE_BASE/data/documents/" "$DEST_BASE/data/documents/" >> "$LOG_FILE" 2>&1 if [ $? -eq 0 ]; then echo "documents sync successful." >> "$LOG_FILE" else echo "ERROR: documents sync failed!" >> "$LOG_FILE" ERROR_FOUND=1 fi echo "----------------------------" >> "$LOG_FILE" #backup echo "Syncing backup..." >> "$LOG_FILE" mkdir -p "$DEST_BASE/backup/" rsync -avX --delete --stats "$SOURCE_BASE/backup/" "$DEST_BASE/backup/" >> "$LOG_FILE" 2>&1 if [ $? -eq 0 ]; then echo "backup sync successful." >> "$LOG_FILE" else echo "ERROR: backup sync failed!" >> "$LOG_FILE" ERROR_FOUND=1 fi echo "----------------------------" >> "$LOG_FILE" # --- UNMOUNT DRIVE --- echo "Unmounting $DEST_BASE..." >> "$LOG_FILE" sync # Flush any remaining data to the disk hardware /usr/local/sbin/rc.unassigned umount "$DEST_BASE" # --- FINAL NOTIFICATION --- if [ "$ERROR_FOUND" == "1" ]; then #send notification in dashboard /usr/local/emhttp/webGui/scripts/notify -i alert -s "Backup to $DEST_BASE" -d "Backup finished with ERRORS. Check $LOG_FILE" else #send notification in dashboard /usr/local/emhttp/webGui/scripts/notify -i normal -s "Backup to $DEST_BASE" -d "All folders backed up successfully. Log saved." fielse #send notification in dashboard /usr/local/emhttp/webGui/scripts/notify -i alert -s "Backup to $DEST_BASE" -d "Backup FAILED: Destination drive not mounted. Log could not be created." exit 1fi
January 14Jan 14 Author 4 hours ago, JorgeB said:Is there anything else logged in the syslog when these show?This is from the sys log when i attempted to run the script a second time this morning. Not sure if the last line has anything to do with it:Jan 14 09:43:08 Server unassigned.devices: Mounting partition 'sdf1' at mountpoint '/mnt/disks/External_HDD_1TB'...Jan 14 09:43:08 Server unassigned.devices: Mount cmd: /sbin/mount -t 'ntfs' -o rw,relatime,nodev,nosuid,nls=utf8,umask=000 '/dev/sdf1' '/mnt/disks/External_HDD_1TB'Jan 14 09:43:09 Server ntfs-3g[3607088]: Version 2022.10.3 integrated FUSE 27Jan 14 09:43:09 Server ntfs-3g[3607088]: Mounted /dev/sdf1 (Read-Write, label "External HDD 1TB", NTFS 3.1)Jan 14 09:43:09 Server ntfs-3g[3607088]: Cmdline options: rw,relatime,nodev,nosuid,nls=utf8,umask=000Jan 14 09:43:09 Server ntfs-3g[3607088]: Mount options: nodev,nosuid,nls=utf8,allow_other,nonempty,relatime,rw,default_permissions,fsname=/dev/sdf1,blkdev,blksize=4096Jan 14 09:43:09 Server ntfs-3g[3607088]: Global ownership and permissions enforced, configuration type 1Jan 14 09:43:09 Server unassigned.devices: Successfully mounted '/dev/sdf1' on '/mnt/disks/External_HDD_1TB'.Jan 14 09:43:09 Server unassigned.devices: Device '/dev/sdf1' is not set to be shared.Jan 14 09:43:39 Server emhttpd: cmd: /usr/local/emhttp/plugins/user.scripts/startScript.sh /tmp/user.scripts/tmpScripts/Backup to External HDD/scriptJan 14 09:45:42 Server monitor_nchan: Stop running nchan processes Edited January 14Jan 14 by rernst
January 14Jan 14 Community Expert Don't see anything relevant there. Asking Gemini about the errors you see, it suggests:This error message indicates that your rsync process was forcibly stopped or interrupted by an external signal, rather than failing due to a data transfer error (like a disk error or permission issue).Here is the breakdown of what specifically happened:1. The Core Meaning: code 20In rsync terminology, exit code 20 specifically means "Received SIGUSR1 or SIGINT." Practically speaking, it means the program was told to quit immediately.2. The Signals (The "Why")The error lists three specific Unix signals that could have caused this. Here is what they usually represent in real-world scenarios:SIGINT (Interrupt): This is the most common cause. It usually happens when you press Ctrl+C in the terminal to cancel the command.SIGHUP (Hang Up): This happens if the terminal window was closed or the SSH connection dropped while the command was still running.SIGTERM (Terminate): This is a generic "stop" command. It might come from a system administrator, a script, or the operating system itself (for example, if the system ran out of memory).3. The Context: [sender] vs [generator]You see two error lines because rsync often spawns multiple processes to do its job.[sender]: The process responsible for reading files and sending data.[generator]: The process responsible for comparing file lists.Both processes received the signal to stop, so both reported the error.Common Scenarios That Cause ThisIf you did not intentionally press Ctrl+C, one of the following likely occurred:Connection Drop: You are running rsync over SSH, and your internet connection flickered, causing the SSH pipe to break (triggering a SIGHUP).Timeout: You are running this via a script or a CI/CD pipeline (like Jenkins or GitHub Actions) that has a time limit, and the job was killed because it took too long.Out of Memory (OOM): If the server is running out of RAM, the Linux "OOM Killer" may have terminated the rsync process to save the system.Parent Process Died: If you ran this from inside another script, and that script crashed, it may have taken rsync down with it.How to Fix ItIf you are running long transfers: Use a tool like tmux or screen, or run the command with nohup. This prevents the process from dying if your terminal window closes or your connection drops.If this is automated: Check the logs of the system running the script to see if a timeout was reached or if the system is running out of memory.
January 15Jan 15 Author i'n not sure which of the above potential causes, is causing the issue; i guess the 'terminal window closing' or connection dropping is the most plausible one.I'll follow this advice and see if it occurs again in the future: 'Use a tool like tmux or screen, or run the command with nohup. This prevents the process from dying if your terminal window closes or your connection drops.'Anyway, I noticed in the log that was created the second time i ran the script (and written to the external disk) , the script continued copying where the first run got stuck. So i ran the script a third time (without any modifications), and now it did copied the remaining files without throwing any rsync errors.Maybe now it doesn't have to copy that much any more in future rsyncs, the errors will not pop up anyway even when using the current unmodified script.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.