Git Product home page Git Product logo

Comments (29)

friisco avatar friisco commented on July 19, 2024 1

My english seems to be not clear :-). I was of course ready with PMS backups because I knew that I would mess up with SQL, it was a breeze to restore (again and again) while I was crafting the right set of SQL commands ( I have 7 PMS libs and 10 media folders so the SQL command grew up a little bit). My SQL knowledge is below entry level so I was doing "try and fail". So no worries, everything went as per the plan and now your script runs perfectly well and the PMS restart has no more issue after going UNC. Thanks Alek

from plexbackup.

mpk99 avatar mpk99 commented on July 19, 2024 1

@mpk99 This one has been bugging me for a few years and I still have no idea what causes it. Nothing I tried worked and I could not find a meaningful explanation from Microsoft on why a script running from a scheduled task would have this issue and an interactive script would not. Makes no sense. And don't know what you can do to help. Thanks for the offer, though.

Ok, I have one more thing i'm going to try later and see if it works and let you know. It's a bit of a long shot, but worth a try nonetheless.

from plexbackup.

54ty1BkRU5zyEvsQ avatar 54ty1BkRU5zyEvsQ commented on July 19, 2024 1

My workaround is to turn off automatic PMS restart in your script and have a batch file run PMS restart when I can be reasonably sure the backup script has finished. For some reason it can access my NAS if I do it that way.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

What do you have on the Synology NAS share: backup folder, Plex app data, media?

from plexbackup.

friisco avatar friisco commented on July 19, 2024

NAS: the media (photos, music, movies...)
Backup folder: on USB local drive connected to WIN10 server (Intel NUC)
Plex APP and database: on nuc server

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

Hm... Then NAS is not in play in the backup process at all. I mean, the backup script does not touch the NAS shares, right? Or did I miss something?

from plexbackup.

friisco avatar friisco commented on July 19, 2024

Correct, Backup script is "unaware" of the NAS and everything goes well during the backup process. This must be due to the Task execution context because if I run the the backup script in the current session I don't have this error. Another symptom is that once I configured to write the logs somewhere in the C: drive and I got an insufficient privilege write error. I must test once again the interactive backup execution because I didn't tried again after the change to a local account setup but I bet it will work as well.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

I am not sure I follow your Plex server account changes (described in the first post). Changing the account under which Plex runs is a big deal (since all settings and data are account-specific). But regardless, the scheduled task (or the interactive backup session) must run under the same account as Plex Media Server (so it has the same permissions, and can access the same registry key and folders). It can be local or domain account, does not matter. In my case, the configuration looks similar to yours (PMS running on a NUC, media on a NAS), although I back up also to the same NAS share (but to a different subfolder). It worked fine, but on the last run I got an error, so I am trying to figure out what is happening there (I opened an issue), but when it ran, it was fine. I do not need the NAS share or folders mapped, though, since I used UNC paths in Plex library configurations (that was a recommendation, and I had to run a manual SQL script to update settings to use UNC paths). The only thing that is a bit weird is the Plex system tray icon, which shows duplicates until the tray refreshes (I suspect it's because of the way PowerShell stops the Plex Media Server process). Anyway, if you have any additional info, or find out something, please let me know. If you have the instructions how to duplicate the problem, I'll take a look, but I need to close my other issue first.

from plexbackup.

friisco avatar friisco commented on July 19, 2024

Microsoft account can be associated with multiple devices you own, syncing files, apps, and Windows settings contrary to a local account. Once, I thought that migrating from MSA to local one would use a distinct profile, by googling around it appears this is not the case. Profile is the same on %USERPROFILE%, the UID on registry is the same and after the migration (using "Sign in with a local account instead" from "Settings / Your Info", the session was strictly the same that before. I believe that there is no root cause to look for in that area.

I've executed the script from the PMS session and, same issue with media unavailable in PMS. No error in log, all went fine

I'll implement your suggestion to use UNC instead and I'll let you know

A workaround would be to add a "reboot" switch to the script in order to let Windows load PMS in the right context

Except Win10 home the server config is quite straightforward, it's a PMS dedicated server with no customizations, user has admin rights

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

If you want to replace mapped drive setting to UNC-based paths, you can use SQL Lite. Here are the commands (make sure you back up the library file first; the following samples change library paths from the mapped Z drive to UNC for MYNAS; run the select statements before executing the update to be sure):

sqlite3 "%localappdata%\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db"
select * from section_locations where where root_path like 'Z:\%';
update section_locations set root_path=replace(root_path, 'Z:\', '\\MYNAS\') where root_path like 'Z:\%';

select * from metadata_items where guid like '%file:%';

select * from media_streams where url like '%file:%';
update media_streams set url=replace(url, 'file://Z:\', 'file://\\MYNAS\') where url like '%file://Z:\%';

select * from media_parts where file like 'Z:\%';
update media_parts set file=replace(file, 'Z:\', '\\MYNAS\') where file like 'Z:\%';

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

Regarding your suggestion to add the reboot switch, it won't do good, since Plex requires a user to be logged in (unless you run PMS as a Windows service), and while it can reboot the computer, it won't be able to get PMS started and the idea is to leave PMS in the original state. I'm still not clear what is not working in your scenario and why mapped drives would be dropped. Makes no sense to me.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

I'll close it for now. If you have any updates, let me know or reopen it (not sure if you can, if not, I will do).

from plexbackup.

friisco avatar friisco commented on July 19, 2024

I've changed all the PMS paths to UNC and this has solved the issue. This does not explain the reason why mapped drive didn't work but anyway, that's good. Thank you Alek for your support here. The backup was quite helpful because the SQL exercise didn't came well the first time :-). I may open another issue with the log redirection that were triggering insufficient privilege write error.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

I said you should've backed up the database before messing with it in SQL. :-) Anyway, let me know if you run into issues.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

I just had it happen to me, so reopening the issue until I can figure out what is going on. In my case, the media files on a ReadyNas share (configured via UNC paths in the Plex database). It worked fine for months and after last two backups, Plex was not able to play media files because they were unavailable. I had to stop Plex, manually access a share and start Plex to make it work. Totally bizarre.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

I modified the network adapter settings to not allow computer to shut down the device to save power and updated the ReadyNAS OS, and it looks like either of these (probably the former) fixed the issue.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

Oh, man. Happened again, so re-opening.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

One thing I noticed: if I have all users (my kids, wife) logged off before the scheduled backup tasks runs, I do not see this problem (unless it's a coincidence).

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

After testing it for a few weeks, I think the issue is related to multiple accounts. My kids have their own account that they use to access the server running Plex (it runs both server and client). They do not have the right privileges to connect to the NAS share, so the problem seems to occur when the backup runs while my kids account is logged on. I added a feature to 1.6.0 to log off all users except the active one and it seems to help, although I am not 100% sure. For now, I'll close it because I cannot think of anything else I can do.

from plexbackup.

mpk99 avatar mpk99 commented on July 19, 2024

hey Alek,

This one's affecting me, and i don't have multiple accounts logged in. Just my 1 account for PLEX.

Anything i can do to help troubleshoot this for you? I hate having to reboot my system every time the backup occurs...

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

@mpk99 This one has been bugging me for a few years and I still have no idea what causes it. Nothing I tried worked and I could not find a meaningful explanation from Microsoft on why a script running from a scheduled task would have this issue and an interactive script would not. Makes no sense. And don't know what you can do to help. Thanks for the offer, though.

from plexbackup.

mpk99 avatar mpk99 commented on July 19, 2024

So my theory didnt' work. Here's what i tried.

Installed WSL2 and ran powershell from inside WSL2 and it ran the script perfectly fine, did the backup, sent me an email to confirm success, but STILL can't access the NAS after restart of the PLEX service.

So it seems it's not only task scheduler that's the problem, i was gonna try to run it thru cron in wsl2, but seems that's not an option either.

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

So you have an issue even if you run the script interactively (not via a scheduled task)?

from plexbackup.

mpk99 avatar mpk99 commented on July 19, 2024

So you have an issue even if you run the script interactively (not via a scheduled task)?

In windows, no, it works fine Interactively. I just ran it in WSL2 (Ubuntu) and it gave that same error as Scheduled Task does...

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

Ah, okay, then we're back to square one.

from plexbackup.

54ty1BkRU5zyEvsQ avatar 54ty1BkRU5zyEvsQ commented on July 19, 2024

I'm having the same issue. Once the script runs and restarts plex, PMS has no access to any NAS content. I've made sure both windows and the NAS folder have read permissions via both Guest and "Everyone". Restarting PMS has always fixed the problem. Is there a way to trigger the restart as the currently logged in user or manually specified user instead of general system account when running it as a scheduled task?

runas /trustlevel:0x20000 "$Script:PlexServerPath" - i think this is where its getting messy

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

@54ty1BkRU5zyEvsQ: I'm still not sure what causes it and why. The runas command in the scheduler (I assume you have this issue when runnning backup as a scheduled job), is supposed to run as the specific user you configure it for (under the scheduler security options). Technically, you can explicitly define the credentials of the user you want to run PMS as, but then you need to save the password somwehere and I'm not sure I want to do it (it will complicate an already complex script). I suspect it's some sort of bug in the Windows scheduler, but at this point, I have no good solution other than restarting the computer (that's what I do).

from plexbackup.

alekdavis avatar alekdavis commented on July 19, 2024

@54ty1BkRU5zyEvsQ What's in your batch file? Do you start it manually?

from plexbackup.

54ty1BkRU5zyEvsQ avatar 54ty1BkRU5zyEvsQ commented on July 19, 2024

Ah, sorry the batch file & powershell scripts didnt fix it. I have windows task scheduler to start PMS as my logged in user about a half hour after backup starts.

from plexbackup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.