Unassigned Devices - Managing Disk Drives and Remote Shares Outside of The Unraid Array


Recommended Posts

29 minutes ago, Stubbs said:

then build parity, then either rebuild the data from parity

Parity cannot rebuild any data disk that was not in the array when parity was built. (how could it?)

 

Just replace and rebuild, one at a time, keeping the original disks as backups until you are satisfied with the results.

 

That is the normal way to upsize disks, I have done it many, many times, and it works very well.

 

Your way is needlessly complicated, more prone to mistakes or other problems, and won't save any time.

Link to comment
20 minutes ago, trurl said:

Parity cannot rebuild any data disk that was not in the array when parity was built. (how could it?)

 

Just replace and rebuild, one at a time, keeping the original disks as backups until you are satisfied with the results.

 

That is the normal way to upsize disks, I have done it many, many times, and it works very well.

 

Your way is needlessly complicated, more prone to mistakes or other problems, and won't save any time.

Well, the first disk I was planning on installing was the 10TB parity drive. Once parity is established on that, restoring it to each new 10TB disks should be simple.

 

The point of my question in this thread was asking if I could mount the old array disks as unassigned devices. This way I could keep my data available while building the data on the new drives. This way, while I'm building each 10TB disk, I can still keep my Nextcloud & Media data up.

Link to comment
On 9/26/2022 at 2:00 PM, dlandon said:

My point is that you might try to apply an update to the STB because of the older SMB protocol.  I cannot find any information on the log message you are getting.  If everything is working correctly, you can filter those log messages.  The Enhanced Log Plugin allows you to filter log messages.

there is no smb v3 update available, i already looked therefore, but thanks for pointing.

 

as note, tihis came up lately (few weeks ago) and was not always present, just in case somewhere else its popping up ...

and for now i ll use the filter ;) thanks for looking into it.

Link to comment
20 hours ago, Stubbs said:

Well, the first disk I was planning on installing was the 10TB parity drive. Once parity is established on that, restoring it to each new 10TB disks should be simple.

 

The point of my question in this thread was asking if I could mount the old array disks as unassigned devices. This way I could keep my data available while building the data on the new drives. This way, while I'm building each 10TB disk, I can still keep my Nextcloud & Media data up.

Upon reflection, I just realized I'm dumb, and forgot I don't need to do that at all while I'm rebuilding parity, lol.

Link to comment

I hope this is the right place to post this.  It looks like I have a corrupted XFS system that I need to repair.  I have been running this setup without any issues for over a year. The catch is that the file system is located on an iSCSI attached file share accross 10Gig optic, that is mounted using unassigned devices.  Here is a high level diagram of the setup. 

image.png.50a1216eefaa4de6a734629113d43b5b.png

 

Unassigned device as it shows up in main menu (hope you can see it)

image.thumb.png.da6d8a8a4452c9f02aac5cb02de335ae.png

 

 

I cant mount the drive under unassigned devices. This is the error I get when I mount the array with unassigned devices for the iSCSI drive.  Then it reverts back to unmounted

image.png.3e26b6f45e574f782db6d061be6750af.png

 

The drive shows up as dev\sdw so I THINK? the iSCSI interface is working correctly, but this could be cashed from when it was working. I am not too experienced with iSCSI. 

 

I didn't see a way from the GUI to do an xfs_repair, so I tried from the command line.  This is what I get,  the result is that xfs_repair tries to verify superblock and I get  "............" continuously until I ctl^c to break out.

image.thumb.png.b333dc04598f78a018fe507fb7de003c.png

 

Before you ask why I am doing this.

1. I like the docker for nextcloud and the docker system in general in unraid better then freeNAS jails and plugins.

2. the idea was to use the docker in unraid then take advantage of the ZFS files system in freeNAS for better error protection and speed.  Not sure how the speed aspect turned out since freeNAS array is ZFS but when it was connected to unraid the share was formatted XFS, I think that's how it works. To be honest it was hacked this together using several different tutorials and trial and error.. Anyway I didn't do any speed tests but it didn't feel like it was an improvement in speed over unraid.  Yes I am using a 10gb interface between freenas<->Unraid<->Client computer.  I am not sure if it is even using ZFS since it is mounted using XFS.

3. Once I get access to the data, I plan to just run nextcloud on freeNAS since this seems to be more headache then its worth.

 

image.png

Link to comment
4 hours ago, JorgeB said:

You can repair the fs using UD, click here:

image.png

OK I ran the disk check using the checkmark.  Got this result.

 

image.thumb.png.44d397b357a6d9d56623f953b5b73453.png

 

I tried to mount the files system and got this error

 

image.png.c306d2e501d6a02f0b568f8131127055.png

 

Is there any other way to run the log file, or do I have to wipe it and move on?  If I do how much damge would this do, would it end up deleting files?

 

 

Link to comment
1 hour ago, linenoise said:

OK I ran the disk check using the checkmark.  Got this result.

 

image.thumb.png.44d397b357a6d9d56623f953b5b73453.png

 

I tried to mount the files system and got this error

 

image.png.c306d2e501d6a02f0b568f8131127055.png

 

Is there any other way to run the log file, or do I have to wipe it and move on?  If I do how much damge would this do, would it end up deleting files?

 

 

OK I went ahead and deleted the log file.  This worked, I am assuming that the impact deleting the metadata file had was the files that it was confused about placed in a directory called "lost and found", but preliminary scan shows that all the files are there.  Thanks for the quick and helpful response.

 

 

Link to comment
On 9/28/2022 at 7:11 PM, Stubbs said:

Upon reflection, I just realized I'm dumb, and forgot I don't need to do that at all while I'm rebuilding parity, lol.

Still not sure where you are going with this. If you are still thinking about mounting your data disks outside the array, no point in doing that either. The data on the drives are still available even while rebuilding a data disk, but performance for accessing the data will be affected by rebuild, and performance for rebuild will be affected by accessing data.

On 9/27/2022 at 11:02 PM, Stubbs said:

could mount the old array disks as unassigned devices. This way I could keep my data available while building the data on the new drives. This way, while I'm building each 10TB disk, I can still keep my Nextcloud & Media data up.

Maybe something you haven't even considered, but the paths to Unassigned Devices are completely different from those for User Shares, so you would have to reconfigure any paths needed to allow anything to access them as Unassigned.

Link to comment

Hi,

after updating to unraid 6.11 I cannot access my smb-shares that are located at my old nas

 

 

Just to let you know - with Win11 the smb-shares are  still available.

 

Not knowing what to do I set up an nfs-server as an alternative. 

~$ showmount -e
Export list for nas:
/srv/halut-pool/Safe       192.168.72.3
/srv/halut-pool/Multimedia 192.168.72.3
/srv/halut-pool/Data       192.168.72.3
/srv/halut-pool/Backup     192.168.72.3

 

and the shares should be available for unraid:

~# showmount -e 10.246.37.221
Export list for 10.246.37.221:
/srv/halut-pool/Safe       192.168.72.3
/srv/halut-pool/Multimedia 192.168.72.3
/srv/halut-pool/Data       192.168.72.3
/srv/halut-pool/Backup     192.168.72.3

 

The nfs-share can be mounted but - just with smb - cannot be accessed.... After mounting, the nfs share is shown with the correct size etc. but after trying to access the folder this changes to '0' and the system is kind of freezed...
 

Oct  2 10:48:27 HalutNAS unassigned.devices: Adding SMB share '10.246.37.221_Multimedia'.
Oct  2 10:48:27 HalutNAS unassigned.devices: Share settings updated.
Oct  2 10:48:42 HalutNAS unassigned.devices: Removing Remote SMB/NFS share '10.246.37.221:/srv/halut-pool/Multimedia'...
Oct  2 10:48:42 HalutNAS unassigned.devices: Unmounting Remote SMB/NFS Share '10.246.37.221:/srv/halut-pool/Multimedia'...
Oct  2 10:48:42 HalutNAS unassigned.devices: Synching file system on '/mnt/remotes/10.246.37.221_Multimedia'.
Oct  2 10:49:26 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 10:49:29 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 10:49:29 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 10:51:05 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 10:51:08 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 10:51:25 HalutNAS kernel: nfs: server 10.246.37.221 not responding, still trying
Oct  2 10:51:42 HalutNAS kernel: nfs: server 10.246.37.221 not responding, still trying
Oct  2 10:52:39 HalutNAS kernel: nfs: server 10.246.37.221 OK
Oct  2 10:52:39 HalutNAS kernel: nfs: server 10.246.37.221 OK
Oct  2 10:52:39 HalutNAS kernel: nfs: server 10.246.37.221 OK
Oct  2 10:52:39 HalutNAS kernel: traps: lsof[17791] general protection fault ip:14ef58d6b4ee sp:10ab7a996e744e98 error:0 in libc-2.36.so[14ef58d53000+16b000]

I don't know why unassigned.devices is showing that an SMB share is added...?

 

The server is still available by unraid:
 

~# ping 10.246.37.221
PING 10.246.37.221 (10.246.37.221) 56(84) bytes of data.
64 bytes from 10.246.37.221: icmp_seq=1 ttl=63 time=0.422 ms
64 bytes from 10.246.37.221: icmp_seq=2 ttl=63 time=0.309 ms
64 bytes from 10.246.37.221: icmp_seq=3 ttl=63 time=0.315 ms
64 bytes from 10.246.37.221: icmp_seq=4 ttl=63 time=0.521 ms
^C
--- 10.246.37.221 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3095ms
rtt min/avg/max/mdev = 0.309/0.391/0.521/0.087 ms

 

Just like smb it seems - just like @dlandon told me that the the network connection with the 'old server' seems to be lost... But the server is online and reachable....

 

Oct  2 13:22:02 HalutNAS unassigned.devices: Mounting Remote Share '//10.246.37.221/Multimedia'...
Oct  2 13:22:02 HalutNAS unassigned.devices: Mount SMB share '//10.246.37.221/Multimedia' using SMB 3.1.1 protocol.
Oct  2 13:22:02 HalutNAS unassigned.devices: Mount SMB command: /sbin/mount -t cifs -o rw,noserverino,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=99,gid=100,vers=3.1.1,credentials='/tmp/unassigned.devices/credentials_Multimedia' '//10.246.37.221/Multimedia' '/mnt/remotes/10.246.37.221_Multimedia'
Oct  2 13:22:02 HalutNAS kernel: Key type dns_resolver registered
Oct  2 13:22:03 HalutNAS kernel: Key type cifs.idmap registered
Oct  2 13:22:03 HalutNAS kernel: CIFS: Attempting to mount \\10.246.37.221\Multimedia
Oct  2 13:22:03 HalutNAS unassigned.devices: Successfully mounted '//10.246.37.221/Multimedia' on '/mnt/remotes/10.246.37.221_Multimedia'.
Oct  2 13:22:03 HalutNAS unassigned.devices: Adding SMB share '10.246.37.221_Multimedia'.
Oct  2 13:22:38 HalutNAS  ntpd[1823]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
Oct  2 13:24:30 HalutNAS kernel: mdcmd (38): nocheck cancel
Oct  2 13:24:30 HalutNAS kernel: md: recovery thread: exit status: -4
Oct  2 13:24:31 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:24:31 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:24:31 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:24:34 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:26:10 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:26:13 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:26:31 HalutNAS kernel: CIFS: VFS: \\10.246.37.221 has not responded in 180 seconds. Reconnecting...
Oct  2 13:26:31 HalutNAS kernel: traps: lsof[27149] general protection fault ip:149d88e644ee sp:e3d51e59235f6a0f error:0 in libc-2.36.so[149d88e4c000+16b000]
Oct  2 13:27:00 HalutNAS root: Fix Common Problems Version 2022.09.26
Oct  2 13:27:49 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:27:52 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:27:52 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:29:28 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:29:31 HalutNAS unassigned.devices: Warning: shell_exec(/bin/df '/mnt/remotes/10.246.37.221_Multimedia' --output=size,used,avail | /bin/grep -v '1K-blocks' 2>/dev/null) took longer than 5s!
Oct  2 13:29:37 HalutNAS kernel: CIFS: VFS: \\10.246.37.221 has not responded in 180 seconds. Reconnecting...
Oct  2 13:29:37 HalutNAS kernel: CIFS: reconnect tcon failed rc = -11
Oct  2 13:29:37 HalutNAS kernel: traps: lsof[8829] general protection fault ip:14725f1ed4ee sp:df2e31cdfd88e67e error:0 in libc-2.36.so[14725f1d5000+16b000]

 

This brings up the question which nic is it that unassigned devices is using? I have changed eth0 to another mac as unraid is always using the 1Gb-nic as eth0 by default which I do not use. I do have a dual 10Gb-nic with one nic being handed over to my Win11-VM and the other being the 'new' unraid eth0. 

Any help is kindly appreciated as I don't know how to use unraid while not being able to copy the 'old nas-files' to the new unraid-shares. 

Kind regards,
 

 

Edited by DerTom
Link to comment
4 minutes ago, DerTom said:

The nfs-share can be mounted but - just with smb - cannot be accessed.... After mounting, the nfs share is shown with the correct size etc. but after trying to access the folder this changes to '0' and the system is kind of freezed...

Your remote server is dropping off-line and the command to determine share sizes ('df') is timing out.  That's why zero is showing for the share size.

 

6 minutes ago, DerTom said:

Just like smb it seems - just like @dlandon told me that the the network connection with the 'old server' seems to be lost... But the server is online and reachable....

It may be reachable, but is probably having errors that CIFS and NFS can't resolve - like timeouts.   Check the logs of your NAS and see it there are errors showing.

 

10 minutes ago, DerTom said:

I don't know why unassigned.devices is showing that an SMB share is added...?

If the Share switch is turned on for a device, UD will create a local SMB share for the remote share.  The Share switch is in the "Device Settings" - the three gears icon.

 

8 minutes ago, DerTom said:

This brings up the question which nic is it that unassigned devices is using? I have changed eth0 to another mac as unraid is always using the 1Gb-nic as eth0 by default which I do not use. I do have a dual 10Gb-nic with one nic being handed over to my Win11-VM and the other being the 'new' unraid eth0. 

The same one that Unraid is using.

 

Post your diagnostics file.

Link to comment

Firstly thanks to everyone for there efforts on making this ecosystem a reality, I'm a noob to Unraid but so glad I've left Qnap behind me.

 

So I've searched for an answer to these to questions but to no avail, first being is there any way to abort / stop a script that is currently running (after I've pressed "MOUNT" and is showing "RUNNING")

 

Which leads me top my next question, is there a way to  "MOUNT" a device without running its attached script (I'm aware its possible to delete the script & save prior to mounting , but its a very round about way as I will need to copy the script back over)

 

Would be nice to a have a disable script button 

 

Thanks

Link to comment

To answer my 2nd question, I've realised i can save a Blank script and save it without overwriting my desired script, that was before I mount the device I can load and the saved blank script and load the desired script when required.

 

Still it would be nice to have a quick "disable script" button beside the "mount" button

Link to comment
9 minutes ago, wacko37 said:

Firstly thanks to everyone for there efforts on making this ecosystem a reality, I'm a noob to Unraid but so glad I've left Qnap behind me.

 

So I've searched for an answer to these to questions but to no avail, first being is there any way to abort / stop a script that is currently running (after I've pressed "MOUNT" and is showing "RUNNING")

 

Which leads me top my next question, is there a way to  "MOUNT" a device without running its attached script (I'm aware its possible to delete the script & save prior to mounting , but its a very round about way as I will need to copy the script back over)

 

Would be nice to a have a disable script button 

 

Thanks

 

There is code in the script to differentiate between a hotplug event and a user event - clicking the "Mount" button.

  'ADD' )
    if [ "$OWNER" = "udev" ]; then
        # do your hotplug stuff here
        sleep 1
    else
        # do your user initiated stuff here
        sleep 1
    fi

The "user initiated stuff" can be used to exit the script when the user clicks the "Mount" button if you don't want the script to run.

Link to comment
5 minutes ago, dlandon said:

 

There is code in the script to differentiate between a hotplug event and a user event - clicking the "Mount" button.

  'ADD' )
    if [ "$OWNER" = "udev" ]; then
        # do your hotplug stuff here
        sleep 1
    else
        # do your user initiated stuff here
        sleep 1
    fi

The "user initiated stuff" can be used to exit the script when the user clicks the "Mount" button if you don't want the script to run.

Thanks for the speed reply, I added the last to lines which where not present in the script "sleep 1 & fi" 

 

Device mounted fine without running the script, was meant to have an option to run the script prior to mounting?

Link to comment

forgive as this is all new to me, I found a script that fitted my use case perfectly, the only way I have found to run the script is when i click the mount button, but sometime I require to mount the device without running the script. Am I totally missing something (most likely am)

 

the script im using is as follows

#!/bin/bash
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

########
# SIMPLE MIRROR BACKUP / V01 -  2022-07-14 / by cholzer 
# This script is meant to be used in the script area of a disk inside the Unassigned Devices plugin
########
# I stitched together this backup script as I could not find a solution for my Offline Backups which are done onto hot-swapable disks.
# With this script you can define multiple backup jobs - you get a notification for each important action.
#
# The whole backup process gets super easy if you choose to enable "automount" for the disk in Unassigned Devices and enable "unmount" in the config section below then .
# Just plug in the disk and the script starts the backup and unmounts the disk once it is done so that you can safely unplug the disk.
# 
########
# Do your modifications below
########

# Here you can setup all your backup jobs.
# The mountpoint of the disk you add this script to inside Unassigned Devices is automatically used as destination target. 
# You can set a subfolder per backup if you'd like to use one.
# Use Unraids new file manager to find the exact source path (available in Unraid 6.10 and later)
backup_jobs=(
# sourcePath                     # destinationPath-Subfolder (/ for none)               #jobName
"/mnt/user/Multimedia/Pictures"                                  "/"                                              "Pictures"
)

# Unmount the backup disk - (Will only be done if the backup was successful)
unmount_after_backup=0

# Notifications:
# You can disable notifications if you really want to.
notifications=1

# rsync options which are used while creating the full and incremental backup
rsync_options=(
  --human-readable # output numbers in a human-readable format
  --delete # when a file was deleted in source directory it will be delete in the destination directory too
  --exclude="[Tt][Ee][Mm][Pp]/" # exclude dirs with the name "temp" or "Temp" or "TEMP"
  --exclude="[Tt][Mm][Pp]/" # exclude dirs with the name "tmp" or "Tmp" or "TMP"
  --exclude="Cache/" # exclude dirs with the name "Cache"
  --exclude=".Recycle.Bin/" # exclude dirs with the name ".Recycle.Bin"
)

####
# WARNING! DRAGONS BELOW! Do not change anything that comes next unless you know what you are doing!
####

## Available variables:
# ACTION     : if mounting, ADD; if unmounting, UNMOUNT; if unmounted, REMOVE; if error, ERROR_MOUNT, ERROR_UNMOUNT
# DEVICE     : partition device, e.g. /dev/sda1
# SERIAL     : disk serial number
# LABEL      : partition label
# LUKS       : if the device is encrypted, this is the partition device, e.g. /dev/sda1
# FSTYPE     : partition filesystem
# MOUNTPOINT : where the partition is mounted
# OWNER      : "udev" if executed by UDEV, otherwise "user"
# PROG_NAME  : program name of this script
# LOGFILE    : log file for this script

case $ACTION in
  'ADD' )
    if [ "$OWNER" = "udev" ]; then
        # do your hotplug stuff here
		sleep 1
    else
        # do your user initiated stuff here
                sleep 1
    fi
	
    # sync the file system to commit all writes to disk
    sync -f "$MOUNTPOINT"
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Device mounted" -i "normal"
	fi
	
	######## Lets run the Backup Job(s)
	# remove the trailing slash from the source and destination path should there be one
	remove_trailing_slash() { [[ "${1%?}" ]] && [[ "${1: -1}" == "/" ]] && echo "${1%?}" || echo "$1"; }
	# now lets loop through each individual backup job
	for i in "${!backup_jobs[@]}"; do
    case $(($i % 3)) in
        0) src_path="${backup_jobs[i]}"; continue ;;
        1) dst_path="$MOUNTPOINT${backup_jobs[i]}"; continue ;;
        2) job_name="${backup_jobs[i]}" ;;
    esac
				
		# check user settings
		src_path=$(remove_trailing_slash "$src_path")
		dst_path=$(remove_trailing_slash "$dst_path")
                echo "Source Path is $src_path" "Destination Path is $dst_path"
		
		# Notification Backup Started
		if [ "$notifications" == 1 ]; then
		/usr/local/emhttp/webGui/scripts/notify -s "`hostname` Backup Job: "$job_name" started" -d "Sync started. `date`"
	    fi

		# first we need to make sure that the log directory does exists, if it doesn't, create it
		if [ ! -d "$MOUNTPOINT"/rsync-logs/"$job_name"/ ]; then
		mkdir -p "$MOUNTPOINT"/rsync-logs/"$job_name"/;
		fi
	
		# Now lets run the actual backup job. 
		# It does a mirror, which means that all changes including deletions are pushed from the source directory to the destination directory.
		# Folders named '.Recycle.Bin' are excluded
		rsync -av --log-file="$MOUNTPOINT"/rsync-logs/"$job_name"/log.`date '+%Y_%m_%d__%H_%M_%S'`.log --progress "${rsync_options[@]}" "$src_path" "$dst_path"

		# Notifications sync complete or error
		if [ "$notifications" == 1 ]; then
			latestRsyncLog=$(ls -tr "$MOUNTPOINT"/rsync-logs/"$job_name"/ |tail -1)
			if [ $? -eq 0 ]
			then
			/usr/local/emhttp/webGui/scripts/notify -s "`hostname` Backup Job: "$job_name" completed" -d "Sync okay! `date`"
			else
			/usr/local/emhttp/webGui/scripts/notify -s "`hostname` Backup Job: "$job_name"  FAILED" -i "alert" -d "Sync ERROR! `date`" -m "`tail -5 "$MOUNTPOINT"/rsync-logs/"$job_name"/"$latestRsyncLog"`"
			fi
		fi
	done
    sleep 1
		
    fi
	
	# unmount the backup disk once the rsync backup finished
	if [ "$unmount_after_backup" == 1 ]; then
	/usr/local/sbin/rc.unassigned umount $DEVICE
    fi
  ;;

  'UNMOUNT' )
    # do your stuff here
	# since we also get notified once the disk was unmounted, I commented this notification out
    # /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Device unmounting" -i "normal"
  ;;

  'REMOVE' )
    # do your stuff here
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Device unmounted" -i "normal"
	fi
  ;;

  'ERROR_MOUNT' )
    # do your stuff here
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Error mounting device" -i "alert"
	fi
  ;;

  'ERROR_UNMOUNT' )
    # do your stuff here
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Error unmounting device" -i "alert"
	fi
  ;;
esac

 

Link to comment

TBH, I've overcome the 1st problem of not running the script or running the desired script when required, it was my lack of understand on how the profiles where being saved / deleted.

 

Is it possible to stop an active / running script?

 

Edited by wacko37
Link to comment
3 minutes ago, wacko37 said:
    else
        # do your user initiated stuff here
        exit
    fi

 

Put an exit where I show here.  When you click on the "Mount" button, the script will exit without running.

 

Then click on the lightning icon:

Screenshot 2022-10-06 192049.png

to run the script whenever the disk is mounted.

Link to comment
28 minutes ago, dlandon said:

Put an exit where I show here.  When you click on the "Mount" button, the script will exit without running.

 

Then click on the lightning icon:

Screenshot 2022-10-06 192049.png

to run the script whenever the disk is mounted.

 

lol....I'm back, I keep getting and error after the "fi"

 

Quote

Executing: 05_-_Videos_-__Pictures_-_Music_-_SYNC.sh 2>&1

/tmp/unassigned.devices/scripts/05_-_Videos_-__Pictures_-_Music_-_SYNC.sh: line 123: syntax error near unexpected token `fi'
/tmp/unassigned.devices/scripts/05_-_Videos_-__Pictures_-_Music_-_SYNC.sh: line 123: ` fi'

 

Again I've attached the script to help

 

#!/bin/bash
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

########
# SIMPLE MIRROR BACKUP / V01 -  2022-07-14 / by cholzer 
# This script is meant to be used in the script area of a disk inside the Unassigned Devices plugin
########
# I stitched together this backup script as I could not find a solution for my Offline Backups which are done onto hot-swapable disks.
# With this script you can define multiple backup jobs - you get a notification for each important action.
#
# The whole backup process gets super easy if you choose to enable "automount" for the disk in Unassigned Devices and enable "unmount" in the config section below then .
# Just plug in the disk and the script starts the backup and unmounts the disk once it is done so that you can safely unplug the disk.
# 
########
# Do your modifications below
########

# Here you can setup all your backup jobs.
# The mountpoint of the disk you add this script to inside Unassigned Devices is automatically used as destination target. 
# You can set a subfolder per backup if you'd like to use one.
# Use Unraids new file manager to find the exact source path (available in Unraid 6.10 and later)
backup_jobs=(
# sourcePath                     # destinationPath-Subfolder (/ for none)               #jobName
"/mnt/user/Multimedia/Music"            "/"                                              "Music"
"/mnt/user/Multimedia/Pictures"                                  "/"                                              "Pictures"
"/mnt/user/Multimedia/Videos"                            "/"                                              "Videos"
)

# Unmount the backup disk - (Will only be done if the backup was successful)
unmount_after_backup=0

# Notifications:
# You can disable notifications if you really want to.
notifications=1

# rsync options which are used while creating the full and incremental backup
rsync_options=(
  --human-readable # output numbers in a human-readable format
  --delete # when a file was deleted in source directory it will be delete in the destination directory too
  --exclude="[Tt][Ee][Mm][Pp]/" # exclude dirs with the name "temp" or "Temp" or "TEMP"
  --exclude="[Tt][Mm][Pp]/" # exclude dirs with the name "tmp" or "Tmp" or "TMP"
  --exclude="Cache/" # exclude dirs with the name "Cache"
  --exclude=".Recycle.Bin/" # exclude dirs with the name ".Recycle.Bin"
)

####
# WARNING! DRAGONS BELOW! Do not change anything that comes next unless you know what you are doing!
####

## Available variables:
# ACTION     : if mounting, ADD; if unmounting, UNMOUNT; if unmounted, REMOVE; if error, ERROR_MOUNT, ERROR_UNMOUNT
# DEVICE     : partition device, e.g. /dev/sda1
# SERIAL     : disk serial number
# LABEL      : partition label
# LUKS       : if the device is encrypted, this is the partition device, e.g. /dev/sda1
# FSTYPE     : partition filesystem
# MOUNTPOINT : where the partition is mounted
# OWNER      : "udev" if executed by UDEV, otherwise "user"
# PROG_NAME  : program name of this script
# LOGFILE    : log file for this script

case $ACTION in
  'ADD' )
    if [ "$OWNER" = "udev" ]; then
        # do your hotplug stuff here
		sleep 1
    else
        # do your user initiated stuff here
        exit
    fi
		
    # sync the file system to commit all writes to disk
    sync -f "$MOUNTPOINT"
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Device mounted" -i "normal"
	fi
	
	######## Lets run the Backup Job(s)
	# remove the trailing slash from the source and destination path should there be one
	remove_trailing_slash() { [[ "${1%?}" ]] && [[ "${1: -1}" == "/" ]] && echo "${1%?}" || echo "$1"; }
	# now lets loop through each individual backup job
	for i in "${!backup_jobs[@]}"; do
    case $(($i % 3)) in
        0) src_path="${backup_jobs[i]}"; continue ;;
        1) dst_path="$MOUNTPOINT${backup_jobs[i]}"; continue ;;
        2) job_name="${backup_jobs[i]}" ;;
    esac
				
		# check user settings
		src_path=$(remove_trailing_slash "$src_path")
		dst_path=$(remove_trailing_slash "$dst_path")
                echo "Source Path is $src_path" "Destination Path is $dst_path"
		
		# Notification Backup Started
		if [ "$notifications" == 1 ]; then
		/usr/local/emhttp/webGui/scripts/notify -s "`hostname` Backup Job: "$job_name" started" -d "Sync started. `date`"
	    fi

		# first we need to make sure that the log directory does exists, if it doesn't, create it
		if [ ! -d "$MOUNTPOINT"/rsync-logs/"$job_name"/ ]; then
		mkdir -p "$MOUNTPOINT"/rsync-logs/"$job_name"/;
		fi
	
		# Now lets run the actual backup job. 
		# It does a mirror, which means that all changes including deletions are pushed from the source directory to the destination directory.
		# Folders named '.Recycle.Bin' are excluded
		rsync -av --log-file="$MOUNTPOINT"/rsync-logs/"$job_name"/log.`date '+%Y_%m_%d__%H_%M_%S'`.log --progress "${rsync_options[@]}" "$src_path" "$dst_path"

		# Notifications sync complete or error
		if [ "$notifications" == 1 ]; then
			latestRsyncLog=$(ls -tr "$MOUNTPOINT"/rsync-logs/"$job_name"/ |tail -1)
			if [ $? -eq 0 ]
			then
			/usr/local/emhttp/webGui/scripts/notify -s "`hostname` Backup Job: "$job_name" completed" -d "Sync okay! `date`"
			else
			/usr/local/emhttp/webGui/scripts/notify -s "`hostname` Backup Job: "$job_name"  FAILED" -i "alert" -d "Sync ERROR! `date`" -m "`tail -5 "$MOUNTPOINT"/rsync-logs/"$job_name"/"$latestRsyncLog"`"
			fi
		fi
	done
    sleep 1
		
    fi
	
	# unmount the backup disk once the rsync backup finished
	if [ "$unmount_after_backup" == 1 ]; then
	/usr/local/sbin/rc.unassigned umount $DEVICE
    fi
  ;;

  'UNMOUNT' )
    # do your stuff here
	# since we also get notified once the disk was unmounted, I commented this notification out
    # /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Device unmounting" -i "normal"
  ;;

  'REMOVE' )
    # do your stuff here
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Device unmounted" -i "normal"
	fi
  ;;

  'ERROR_MOUNT' )
    # do your stuff here
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Error mounting device" -i "alert"
	fi
  ;;

  'ERROR_UNMOUNT' )
    # do your stuff here
	# notification
	if [ "$notifications" == 1 ]; then
    /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Unassigned Devices" -d "Error unmounting device" -i "alert"
	fi
  ;;
esac

 

Edited by wacko37
Link to comment

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.