Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

how do you Rsync and cause it to delete Duplicated Files when a Drive Fails

Featured Replies

my problem i noticed is i rsync from one server to backup server..  now  on the backup server 1 drive failed i had to run the xfs_repair -L  after googling.  but i didnt know drive lost its partition  so its been rysncing to the rest of the drives and filled it up..   as i noticed the server on too long and the rysncing showed out of disk space..  

as what i backing up is only 43TB  total array is 56TB  and when i fixed the drive  its 1TB free and its 55TB used  not 43TB used...  i deleted the lost+found folder but it deleted 2gb.. i ran the rysnc --delete   but i guessing duplicated files  are now on the other drives  cuz of the 1 failure...  so say 

this is my movie.mp4  was on the failed drive but now its on the other drives...  buy the rysnc --delete doesnt delete the 2 copies now

 

is there a way to force rysync to delete the duplicate copies.. i tried looking at ubalance  but it didnt have any feature like that..  or do you just format all the drives and resync over to get back to 43tb  instead..  

 

i guess thats what they call symb links  as it points the file to a certain drive  but now i have 2 copies of same file... and is there a way to Unraid  when a drive fails..  to text me  to Send to HOME ASSISTANT... or an email or so..  or is there a way to not allow Rsync to run on the host side when the remote side a Drive failed...  is there any options like that out there?

 

  • Community Expert

1. Difference Between rsync vs Copying Files

cp (copy): blindly copies files from source to destination. Every file, always, unless you tell it otherwise.

 

rsync: syncs — it only transfers changes (new/modified files) to the destination.

--But if the file at destination is corrupted or missing, rsync trusts what it sees — and may overwrite it, or skip it, depending on your options (--checksum, etc.).

 

If a file becomes corrupted (0 bytes or unreadable) and rsync runs without strict checks, rsync could replace good files with corrupted ones, or leave duplicated files.

That's exactly what happened to you.

 

2. What went wrong in your situation

 

Your backup server's one drive failed silently. You ran xfs_repair -L, which lost metadata (because -L forces a repair, but nukes bad journal areas).

After that, rsync kept running — but because the filesystem was broken, missing files were seen as "gone" and rsync recopied data to the other (still-working) drives.

*Theory - That caused duplicate copies to appear across the drives.

 

Because Unraid uses user shares to "virtually" merge the disks, it looked normal at first — but now you have extra copies of files wasting space.

(Also: lost+found only contained lost orphaned inodes — deleting it barely freed any space.)

 

3. Why rsync --delete didn't fix it

--delete only deletes files at the destination if they are missing from the source.

 

It does not scan for duplicates. If a file exists both on Disk 1 and Disk 2, Unraid's user share may hide that from normal rsync behavior.

 

So rsync thinks everything is fine — it does not delete duplicate files.

There’s no built-in "deduplication" feature in rsync!

 

4. Solutions to Fix Your Problem

Here’s the brutal truth: The data is lost...

 

Option 1: Manual Deduplication — find duplicate files across drives, and delete one copy.

Hard, time-consuming, and requires special tools.

Tools like fdupes, rdfind, or dupeGuru can help find duplicates.

 

Option 2: Wipe and Resync — format the array, wipe all disks, and fresh rsync from the source server.

Cleanest and safest.

Will bring you back to ~43TB usage.

 

Option 3: Partial deduplication — delete files only from the problem disks, then rsync again carefully (more complicated and risky).

👉 Most people would just FORMAT and start fresh in your case.

  • Community Expert

I've had a hard time setting up the unraid alerting features can unraid do these things yes...

The truth is you can eamil as a text.. you can setup email on unraid by connecting to a Gmail / micrsoft account and send a text to your phone via email... (depending on phone network carrier...)

 

Most of the time setting up alerts have additional costs... other maintaince and Good practice is to login 1 a month run updates and check logs... most can be automated...

 

Unraid: Alerts and Automation

You asked:

Can Unraid text me when a drive fails?

YES! look at settings notifications... you can even make a bot with discord...

 

Unraid has built-in notifications (Settings > Notifications).

You can configure:

Email alerts

Telegram alerts

Slack

Pushover

and even Custom Webhooks ➔ which can send directly to Home Assistant.

-Bonus: You can also install Dynamix System Notifications plugin for more advanced options.

 

Can Rsync Detect a Failing Drive?

Not really.
Rsync doesn’t know if a drive has failed — it just copies what it sees.

If the file system is still "mountable" (even corrupted), rsync thinks everything is normal.

➔ You need SMART monitoring or filesystem checks outside of rsync:

Use Unraid SMART Reports (Dashboard > Disks > click on a disk > SMART).

Set threshold triggers to get alerts if reallocated sectors, pending sectors, or other errors appear.

You can schedule Parity Checks and Filesystem Checks too.

However there are adatial things you can run along side...

 

Some Extra Notes...

If you want to rsync safely in the future, consider using:

review: https://linux.die.net/man/1/rsync

 

rsync -avP --delete --checksum /source/ /destination/

-a = archive mode

-v = verbose

-P = show progress

--delete = delete extraneous files

--checksum = compare files based on checksum, not size and timestamp.

This prevents corrupt files from overwriting healthy ones if the size didn't change but content did.

 

We’ll review important rsync options first (to make sure your backups are as safe as possible), then I’ll write you a "smart rsync watchdog" script that auto-stops rsync if a disk shows signs of failure.

 

More proof of concept and examples....

Additional rsync options we will use...

image.png.a9b5ebda7a7096e53b09341e42e01980.png

 

Example rsync command:

rsync -avP --delete --checksum /mnt/user/myshare/ root@backupserver:/mnt/user/backups/myshare/

 

so this rsync comand can be scripted with another service that can check the disks... n my case lets review watchdog.... (debain based may or may not work in unraid...)

 

 

Here’s the plan:

Monitor disks (SMART health check).

If a disk shows problems (like Pending Sectors or Reallocated Sectors growing),

Kill the rsync process immediately.

Send a warning (log, maybe notification).

 

example rsync_watchdog.sh

#!/bin/bash

# === CONFIGURATION ===
DISKS_TO_MONITOR=("/dev/sdX" "/dev/sdY" "/dev/sdZ")  # Put your disk devices here
RSYNC_PROCESS_NAME="rsync"
THRESHOLD_REALLOCATED=5     # Number of reallocated sectors before considering "failing"
THRESHOLD_PENDING=1         # Number of pending sectors before considering "failing"
LOGFILE="/var/log/rsync_watchdog.log"

# === FUNCTIONS ===
check_disk_health() {
    local disk=$1
    local realloc=$(smartctl -A "$disk" | awk '/Reallocated_Sector_Ct/{print $10}')
    local pending=$(smartctl -A "$disk" | awk '/Current_Pending_Sector/{print $10}')

    realloc=${realloc:-0}
    pending=${pending:-0}

    if (( realloc >= THRESHOLD_REALLOCATED )) || (( pending >= THRESHOLD_PENDING )); then
        echo "$(date '+%F %T') - Disk $disk failing: realloc=$realloc pending=$pending" >> "$LOGFILE"
        return 1
    fi
    return 0
}

stop_rsync() {
    echo "$(date '+%F %T') - Stopping rsync..." >> "$LOGFILE"
    pkill -f "$RSYNC_PROCESS_NAME"
}

# === MAIN LOOP ===
any_disk_failing=0
for disk in "${DISKS_TO_MONITOR[@]}"; do
    if ! check_disk_health "$disk"; then
        any_disk_failing=1
    fi
done

if [[ "$any_disk_failing" -eq 1 ]]; then
    stop_rsync
fi

 

in theory you can use the user script plugiin to run and check the disks...

as unraid already has smartmon data:

image.thumb.png.e998e0e9fa308392bc2459016e18fa5f.png

image.png.35d830edd99c33bb26e09ca1e9ac1e0e.png

 

Essential what happens is:

 

Watchdog detects it.

Rsync is automatically stopped.

You can setup and get an alert (you can add Home Assistant integration next if you want).

 

this bring me back to other solutions now...

 

things such as syncthing, seafile, sftp and other means to transfer files... rsync has its uses and other dockers / plugins exist to help move and tranfer files...

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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.