Jump to content

Library Real Time Monitoring needs SAFETY CHECK


Recommended Posts

Posted (edited)

Hello,

I have a scenario where one of my libraries sits on the external HDD enclosure. I want to have for it Real Time Monitoring enabled but there is a catch.. sometimes happens this external HDD enclosure has connectivity issues or after reboot it did not get properly mounted to the Linux file system and Emby starts purging everything related to it. This is huge pain in case such library is 50k home video files - everything needs to be rebuild from scratch, which can take weeks! I know it kind of makes sense of Real Time Monitoring feature but I would propose to implement a safety check that the library is actually present on the file system. I know this is difficult to detect properly when Emby server is inside docker, but something simple like: If any specified folder is entirely empty, skip the synchronization for it.

So before triggering the real time sync perform for both of this folders this empty folder check:

  • IF contains SOMETHING -> sync
  • IF contains NOTHING -> skip

I would do this safety check also when triggered manually, because many times user don't even notice the external HDD enclosure is not mounted.. 99% of cases user finds out when his media are missing in the Emby library.. In order to sync on these empty libraries user would need to disable safety check.

 

Solution:

image.png.130eb9486c537ad3c1e1f9ade445f48f.png

Edited by MacGyver27
Posted

Hey.
Thanks fore the reply. Unfortunately this happened quite few weeks ago.. but can simulate if necessary.. should be pretty straight forward with docker. Let me know!

  • Thanks 1
Posted

This is not an Emby problem, this is a problem with your hardware being faulty. 

Replace it.

Posted

If your storage is normally mounted to /srv/media then when it's not mounted /srv/media will exist as an empty folder, but /srv/media/YouTube would not. To my knowledge the server already has a check in place wherein if the mapped folder does not exist at all it does not try to scan and delete. You mentioned docker specifically, so I believe if you're running the container with mapped paths and those paths don't exist that it will still map them anyway (it will create the path on the host?), so the Emby server running inside the container would yes see the folders as being empty and then clear out.

It would be better to require your storage to be mounted before starting the docker container, or mapping a lower path instead so that your actual folders would not exist and you would not have that problem. So if you map /srv/media into the container, then only map the library paths as /srv/media/YouTube and /srv/media/.downloads/ADV, if /srv/media is not mounted those folders would not exist and it won't delete anything.

  • Agree 1
MacGyver27
Posted
20 hours ago, RanmaCanada said:

This is not an Emby problem, this is a problem with your hardware being faulty. 

Replace it.

My hardware is not faulty.. It is given when you are using an external HDD enclosure from time to time it wont mount after reboot - there are idle timeouts. When my server is down for longer than 10 minutes and I boot it, this HDD enclosure needs power-cycle, because it is in sleep mode or something..

MacGyver27
Posted (edited)
20 hours ago, Lessaj said:

If your storage is normally mounted to /srv/media then when it's not mounted /srv/media will exist as an empty folder, but /srv/media/YouTube would not. To my knowledge the server already has a check in place wherein if the mapped folder does not exist at all it does not try to scan and delete. You mentioned docker specifically, so I believe if you're running the container with mapped paths and those paths don't exist that it will still map them anyway (it will create the path on the host?), so the Emby server running inside the container would yes see the folders as being empty and then clear out.

Precisely! That's why I said it is tricky via Docker.. only fast solution would be this empty folder check.
 

 

20 hours ago, Lessaj said:

It would be better to require your storage to be mounted before starting the docker container, or mapping a lower path instead so that your actual folders would not exist and you would not have that problem. So if you map /srv/media into the container, then only map the library paths as /srv/media/YouTube and /srv/media/.downloads/ADV, if /srv/media is not mounted those folders would not exist and it won't delete anything.

Correct as well. I can make a health-check to prevent Emby from starting entirely when external mount is not present, but sometimes I maintain this external HDD enclosure and it is not in use and this would mean Emby would not start at all.. Usual scenario is when my RAID array needs a HDD replacement, for safety reasons I keep this HDD enclosure turned off and for this whole period of time - can be 30 days - I would not be able to run Emby server at all, until my RAID array is healthy again.

That is why I proposed this to be implemented into Emby server directly. So you mentioned you have a safety check to skip it in case folder is not preset at all - could you please extend this safety check of a scenario where the folder is also empty?

Thanks a lot!

Edited by MacGyver27
Lessaj
Posted

This is essentially a feature request and should be in the correct forum, but if you mount the paths as suggested you won't need this at all.

  • Agree 1
RanmaCanada
Posted
1 hour ago, MacGyver27 said:

My hardware is not faulty.. It is given when you are using an external HDD enclosure from time to time it wont mount after reboot - there are idle timeouts. When my server is down for longer than 10 minutes and I boot it, this HDD enclosure needs power-cycle, because it is in sleep mode or something..

Your hardware is faulty. It is not a given that an external HDD enclosure won't mount from time to time after reboot. A proper working enclosure will always mount, ALWAYS. As for sleep time, you're just adding that now to defend yourself. Having it go to sleep when it's attached to the server just shows you have no clue what you're doing, which was apparent the moment you said you're using an external drive for your media..Have your system setup CORRECTLY.

I'd argue this is a 100% your problem, not an Emby problem.

Posted (edited)

The issue is you are trying to blame Emby for something that Emby has no control over.

Why is your drive not staying mounted when it goes to sleep? It should still be mounted just goes to sleep. Mine stay this way on both Windows and Linux. The enclosures are USB and they sleep and stay mounted just fine. Why does it not always appear when you boot the PC? 

What type of drives are these? What is the enclosure? As stated by others this isn't an Emby problem. It is a hardware or OS issue. Fix your power plan that is turning off the hard drive after a period of time of no use. That is what this sounds like. You want the drive to always stay mounted and that power plan is causing it to unmount. It can still fall asleep and wake just fine.

image.thumb.png.96e61878f7673a30cbb857189902e743.png

A temporary solution is turn off real time monitoring. Use scan library instead. Then when adding new media navigate to the folder view of that type of library. In this case I've added new media to this particular folder inside my Movies library. Rather than scan the entire library I just want to update this folder. I can do that with scanning just the library in the folder. Did you know you could do this? If you add new media across your libraries just use the normal scan library to cover all. But when adding to just certain folders you can just scan those folders.

If you add a new episode to a series. You can also just click that series name on the 3 dots menu. Find the scan library and just scan in that series. Quickly. It works at any level and will just scan at that level.

Edited by speechles
  • Like 1
Posted
1 hour ago, speechles said:

The issue is you are trying to blame Emby for something that Emby has no control over.

Don't hard drives die? Wouldn't that cause the exact issue OP is on about?

It's reasonable to expect Emby to deal gracefully with unfortunate situations that happen from time to time in the real world.

Posted (edited)
9 minutes ago, C.S. said:

Don't hard drives die? Wouldn't that cause the exact issue OP is on about?

It's reasonable to expect Emby to deal gracefully with unfortunate situations that happen from time to time in the real world.

But if the hard drive is dead. The data is too. Unless you backed it up. Given the prices of drives today. Likely no backup and the data is gone. Most users data is just gone. Poof.

When people want to force an update of a library it is suggested to move that library out and scan. Then moving it back in and scan. This behavior is why that happens. It is expected when the drive isn't there that it isn't there for a reason and likely it will be shortly and can get scanned again.

If you want the OS to notify you the moment the drive becomes unmounted you can do that. But why would Emby need to? The issue has never been mentioned before. There is one person having the problem. This is cause and effect. The cause is unmounting the hard drive. The effect is it gets removed as a library during the scan. But figure out the cause and there is no effect. What is the cause?

Edited by speechles

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...