Jump to content

Good old backup questions + spindown external HDD


Recommended Posts

Hey, i got an external HDD from WD as my backup drive.
Now i need a script or so, to mount the drive for the backup and unmount and spin it down afterwards.
The plugin Appdata Backup seems to do backup stuff fine and i also can enter custom scripts.
I also installed Unassigned Devices to do the mounting, but not sure if and how i can use it via a script.

In Proxmox i simply used this script:

#!/bin/bash
	
if [ "$1" == "job-start" ]; then
	echo '2-4' |tee /sys/bus/usb/drivers/usb/bind
	sleep 30
	mount UUID=6ff3beb2-cfb9-4f0f-a12b-2261be04253d /mnt/backup
fi
if [ "$1" == "job-end" ]; then
	sleep 30
	umount /mnt/backup
	echo '2-4' | tee /sys/bus/usb/drivers/usb/unbind
fi


I had to unbind the USB driver to get the drive to spin down, because i saw no other way back then.
But for Unraid this solution is probably not the best, if its even working.

I found a little program called uhubctl to disable specific USB ports, but no idea how i get that working in Unraid.

I am thankful for any useful tips ^^

Edited by Darkestnoir
New title
Link to comment
  • Darkestnoir changed the title to Good old backup questions + spindown external HDD
10 minutes ago, dlandon said:

Click on the 'Help' icon in the upper right side of the UD UI and read down the page.  You'll see the script commands to manage a UD disk - mounting, unmounting, spinning down, and putting the disk in standby.

This not really helps in any way 😅

 

Let me pack it in one sentence:
I want a automated backup, which is performed by schedule, which mounts my external USB WD HDD and unmount/spindown it afterwards.
 

Problems in that i run.

  • Unraid can't spindown the external USB WD HDD, because WD sucks, had the same problem with proxmox, so i had to unbind the USB driver stack (not really a solution for Unraid).
  • I tried to mount/unmount the HDD with:
    /usr/local/sbin/rc.unassigned mount name=diskname

    But it seems not to work, i tried it via the console, it says "success" but nothing happens.
    I tried different "disknames", either i don't find the correct "diskname" or it just not work.

Link to comment

This is a user script I use to perform a backup to that disk.  It can be done on a schedule with User Scripts.

#!/bin/bash
#description=Backup Music Folder.
#backgroundOnly=true
#arrayStarted=true
#clearLog=true
#
LOGFILE="/tmp/unassigned.devices/logs/Music_Backup.log"

# Mount the backup disk
/usr/local/sbin/rc.unassigned mount name=MusicBk
# Backup the Music folder to the backup disk
rsync -av --delete --exclude .Recycle.Bin '/mnt/user/Music' '/mnt/disks/Music Backup/' 2>&1 >> $LOGFILE
# Unmount the disk
/usr/local/sbin/rc.unassigned umount name=MusicBk
# Spin down the disk
/usr/local/sbin/rc.unassigned spindown name=MusicBk

 

  • Like 1
Link to comment

 

43 minutes ago, dlandon said:

The 'diskname' is the alias you assign to the disk:

Screenshot 2024-02-26 080045.png

Screenshot 2024-02-26 080150.png

Ty, this fixes the second problem.
I used the disk identification/serial, which makes more sense to me, but fine it works.

Why ever it shows "success" but not really does anything with a wrong disk name.
The limit to 8 characters in the disk name is a little bit strange.

 

38 minutes ago, dlandon said:

This is a user script I use to perform a backup to that disk.  It can be done on a schedule with User Scripts.

#!/bin/bash
#description=Backup Music Folder.
#backgroundOnly=true
#arrayStarted=true
#clearLog=true
#
LOGFILE="/tmp/unassigned.devices/logs/Music_Backup.log"

# Mount the backup disk
/usr/local/sbin/rc.unassigned mount name=MusicBk
# Backup the Music folder to the backup disk
rsync -av --delete --exclude .Recycle.Bin '/mnt/user/Music' '/mnt/disks/Music Backup/' 2>&1 >> $LOGFILE
# Unmount the disk
/usr/local/sbin/rc.unassigned umount name=MusicBk
# Spin down the disk
/usr/local/sbin/rc.unassigned spindown name=MusicBk

 

Ty for the script, but like i said, the spindown does not work, the external USB WD drive ignores it.
Even when i detach the disk via the WebUI it does not make a difference.
My internal disk have no issues with spindowns.
I can't unbind the USB driver, because of the Unraid stick and i also want to use other USB devices, i have to disable the specific USB port, like this program does uhubctl.

So is there a way to use that program in Unraid, or do anyone know a other plugin etc.?

Edited by Darkestnoir
Link to comment
1 hour ago, Darkestnoir said:

Why ever it shows "success" but not really does anything with a wrong disk name.

I've made a fix for this.  It will be in the next release.

 

1 hour ago, Darkestnoir said:

The limit to 8 characters in the disk name is a little bit strange.

The GUI is limited in space and a longer alias would take up too much space.

 

1 hour ago, Darkestnoir said:

Even when i detach the disk via the WebUI it does not make a difference.

When the device is detached, it is a very low power mode.  What makes you think it is spinning?

 

Can you spin down the disk using the GUI?

 

There was a change made to allow a USB disk to act more like a SATA device and possibly fix this kind of thing, but the disk still has to handle spinning down.  If you are not using 6.12.8, try upgrading and see if it helps.

  • Like 1
Link to comment
5 hours ago, dlandon said:

I've made a fix for this.  It will be in the next release.

 

The GUI is limited in space and a longer alias would take up too much space.

 

When the device is detached, it is a very low power mode.  What makes you think it is spinning?

 

Can you spin down the disk using the GUI?

 

There was a change made to allow a USB disk to act more like a SATA device and possibly fix this kind of thing, but the disk still has to handle spinning down.  If you are not using 6.12.8, try upgrading and see if it helps.

Ty for the fix.

I think its spins, because the led is not slowly blinking, the drive vibrates and need to much power, also it makes a humming sound 😄

No, the external USB WD disk can't be spin down, Unraid tries it, but the drive just blinks fast for few seconds and then steady again.
I am using 6.12.8 already, just installed it few days ago.
Like i said the only solution is to unplug the drive, unbind the USB driver, maybe ububctl or anything else which disables the USB port.

 

Edit1:
Okay, i detached the drive and after i came back, after few hours, it was spin downed.
It seems it takes a little bit of time until the drive spins down (have to recheck again).
When i just unplug the USB cable it spins down immediately.
I already found the command to detach and attach a disk.
But i can't find the correct device to use the detach command.
Not sure why every cmd needs another name/ID for the same device in the end, when the serial is always available and unique (f.e. WD_Elements_25A3_564748334E355047-0:0 in my case)
The other things like diskname or /dev/sdX or devX designation (which i am not sure were i can find them) can change, which is bad for such a script.
A "fix" for this would be nice @dlandon, so we can just use the serial for every attach, detach, mount, unmount etc. cmd.

Edit2:
It takes 30min until the drive spins down, after detach, not good, but okay.

Edited by Darkestnoir
Link to comment
5 hours ago, Darkestnoir said:

But i can't find the correct device to use the detach command.

When you use the built in device script, the device is passed to the script as $DEVICE.  If you have a stand alone or User Script, the alias 'name=' always works as the device for all the commands.

 

5 hours ago, Darkestnoir said:

Not sure why every cmd needs another name/ID for the same device in the end, when the serial is always available and unique (f.e. WD_Elements_25A3_564748334E355047-0:0 in my case)

The serial is long and very cumbersome.  The alias name is a lot easier.

 

5 hours ago, Darkestnoir said:

The other things like diskname or /dev/sdX or devX designation (which i am not sure were i can find them) can change, which is bad for such a script.

The sdX and devX do change.  That's why $DEVICE is passed in as an environment variable to the device script.  You can use $DEVICE in the built in device script.  UD handles the proper device assignment.

 

5 hours ago, Darkestnoir said:

A "fix" for this would be nice @dlandon, so we can just use the serial for every attach, detach, mount, unmount etc. cmd.

The alias name works for the consistentcy you are looking for.  There is no reason to implement the serial number for the commands.

Link to comment
17 minutes ago, dlandon said:

When you use the built in device script, the device is passed to the script as $DEVICE.  If you have a stand alone or User Script, the alias 'name=' always works as the device for all the commands.

 

The serial is long and very cumbersome.  The alias name is a lot easier.

 

The sdX and devX do change.  That's why $DEVICE is passed in as an environment variable to the device script.  You can use $DEVICE in the built in device script.  UD handles the proper device assignment.

 

The alias name works for the consistentcy you are looking for.  There is no reason to implement the serial number for the commands.

Okay, the i think the serial is the easiest one, because it was the first thing i found and makes sense.
But i still can't find the correct /dev/sdX or devX designation for my drive to detach it:
grafik.png.d77c6a7f4ada75e1e01b88488efa238d.png

grafik.thumb.png.ea8394e69d18abcb3f83de6fa900e402.png

 

Edited by Darkestnoir
Link to comment
18 minutes ago, Darkestnoir said:

But i still can't find the correct /dev/sdX or devX designation for my drive:

You don't need it.  Use the alias you assign and then the device for all commands is 'name=alias'.  In the case of the detach command, 'name-alias' does work.  I see in the UD page it is not documented in the help that the alias can be used.  I'll correct that.

 

Edit: In your case use:

/usr/local/sbin/rc.unassigned detach name=Backup1

 

  • Like 1
Link to comment
22 minutes ago, dlandon said:

You don't need it.  Use the alias you assign and then the device for all commands is 'name=alias'.  In the case of the detach command, 'name-alias' does work.  I see in the UD page it is not documented in the help that the alias can be used.  I'll correct that.

Okay, still not sure what do you mean, i tried all 3 possibility's i can think of, none worked here, see the picture above.

 

Edit:

23 minutes ago, dlandon said:

Edit: In your case use:

/usr/local/sbin/rc.unassigned detach name=Backup1

Ah ty, maybe also add this to the help thing:
 

'/usr/local/sbin/rc.unassigned detach name=diskname' - detach device by disk name.

 

Edited by Darkestnoir
Link to comment

Okay ty with all this, now i got some issues with the Appdata.Backup plugin (because a simple rsync is not enough for me 😅), but i posted it in the appropriate thread.
Not sure which part of this thread i should mark as solution, maybe i just should edit the first post or add a new one with a summary.

 

Edited by Darkestnoir
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.

×
×
  • Create New...