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.

Scripting a mover + rsync combo

Featured Replies

Hey everyone,

I'm fairly new to Unraid, and loving it. Today I'm working on a script that will do the following:

1) Run mover

2) Mount attached unassigned device by serial

3) Use Rsync to synchronize 2 folders to this unassigned device from 2 shares on my array

4) Unmount the unassigned device

 

I have what I believe is a solid solution for parts 2-4 (below), but I'm struggling with getting mover to run first. The reason I'm trying to merge these tasks instead of letting them run on separate schedules, is just to optimize spin-ups. If the disks are spun up to handle the move, I'd rather continue with the sync directly after, rather than spinning them up again an hour later to handle that. It's also partly just to challenge myself to write something.

Thanks.

(Also credit to user CS01-HS, whose code I borrowed for the mounting by serial trick.

#!/bin/bash

#RUN MOVER
#

#MOUNT DISK BY ID (PLUG IN YOUR DISK_ID)
DISK_ID=50_0123456789ABCDEF
THIS_DISK=`ls -l /dev/disk/by-id/ | grep '$DISK_ID' | head -1 | tail -c4`
/usr/local/sbin/rc.unassigned mount "/dev/$THIS_DISK"
if [[ $? -ne 0 ]]; then 
  echo "Exiting due to ERROR."
  exit 1
fi

#RUN SYNC COMMANDS
test -e "/mnt/disks/Mega" && rsync -avh --progress "/mnt/user/Mega/" "/mnt/disks/Mega/2D"
test -e "/mnt/disks/Mega" && rsync -avh --progress "/mnt/user/VR/" "/mnt/disks/Mega/VR"

#UNMOUNT DISK BY ID
/usr/local/sbin/rc.unassigned umount "/dev/$THIS_DISK"

 

Edited by stev067

I added two sections to mover tuning to run script before and/or after mover runs, plus it allows for a "test" mode. (Test at least for the mover part).

 

Else you can just start mover with the "start" argument.

  • Author
1 hour ago, hugenbdd said:

I added two sections to mover tuning to run script before and/or after mover runs, plus it allows for a "test" mode. (Test at least for the mover part).

 

Else you can just start mover with the "start" argument.

Thanks. Running mover by percentage full will make for even fewer spin ups, and I didn't realize I could call scripts from this plugin.

  • Author
2 hours ago, hugenbdd said:

I added two sections to mover tuning to run script before and/or after mover runs, plus it allows for a "test" mode. (Test at least for the mover part).

 

Else you can just start mover with the "start" argument.

 

Any tips on syntax for the before/after script fields? I'm entering this value below, but looking at syslog, it seems the spaces aren't welcome. And trying to add double or single quotes isn't helping. 

 

/boot/config/plugins/user.scripts/scripts/Sync to Raid-50

 

edit: sounds like it's unavoidable. I just renamed the script to have no spaces and hopefully that works.

Edited by stev067

12 minutes ago, stev067 said:

 

Any tips on syntax for the before/after script fields? I'm entering this value below, but looking at syslog, it seems the spaces aren't welcome. And trying to add double or single quotes isn't helping. 

 

/boot/config/plugins/user.scripts/scripts/Sync to Raid-50

 

edit: sounds like it's unavoidable. I just renamed the script to have no spaces and hopefully that works.

Maybe put it in quotes, I didn't test it with spaces.  Generally if possible, you want to avoid spaces as much as possible in directory/file names.

Archived

This topic is now archived and is closed to further replies.

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.