Git Product home page Git Product logo

plexbackup's People

Contributors

alekdavis avatar alekdavisintel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plexbackup's Issues

7zip and Scheduled Plex backup

Hello,

I want to use 7zip with a Scheduled Plex backup.

If I understand, I need to edit PlexBackup.ps1.json like this ?

"Type": {
"_meta": {
"set": ",7zip,Robocopy",
"default": "7zip"
},
"value": null
},

Thank you

an error that I cant fix in the plex backup script (or config file)

Hi Alek

so I have tried to get your powershell script working to backup my plex db

When I execute the script, |I get an error

PS C:\plexbackupscripts> .\plexbackup.ps1
The "=" operator is missing after a named argument.
At C:\plexbackupscripts\PlexBackup.ps1:320 char:26

  • [Parameter(Mandatory, <<<<  ParameterSetName="ModeType")]
    
    • CategoryInfo : ParserError: (:) [], ParseException
    • FullyQualifiedErrorId : MissingEqualsInNamedArgument

the only thing I changed in the config file was to replace "null" in the backup dir with my backup location (which is pasted below) and is on the same drive as the backup script at c:\PlexBackupData"

Any help gratefully received

Thanks

{
"_meta": {
"version": "1.0",
"strict": false,
"description": "Sample run-time settings for the PlexBackup.ps1 script."
},
"Mode": {
"_meta": {
"set": "Backup,Continue,Restore",
"default": "Backup"
},
"value": null
},
"Type": {
"_meta": {
"set": ",7zip,Robocopy",
"default": ""
},
"value": null
},
"PlexAppDataDir": {
"_meta": {
"default": "$env:LOCALAPPDATA\Plex Media Server"
},
"value": null
},
"BackupRootDir": {
"_meta": {
"default": "$PSScriptRoot"
},
"value": "\BackupPlex"
},
"BackupDir": {
"_meta": {
"default": null
},
"value": null
},
"TempDir": {
"_meta": {
"default": "$env:TEMP"
},
"hasValue": true,
"value": null
},
"WakeUpDir": {
"_meta": {
"default": null
},
"value": null
},
"ArchiverPath": {
"_meta": {
"default": "$env:ProgramFiles\7-Zip\7z.exe"
},
"value": null
},
"Quiet": {
"value": null
},
"LogLevel": {
"_meta": {
"default": "None,Error,Warning,Info,Debug"
},
"value": null
},
"Log": {
"value": true
},
"LogFile": {
"value": null
},
"ErrorLog": {
"value": null
},
"ErrorLogFile": {
"value": null
},
"Keep": {
"_meta": {
"range": "0-[int]::MaxValue",
"default": "3"
},
"value": null
},
"Retries": {
"_meta": {
"range": "0-[int]::MaxValue",
"default": "5"
},
"value": null
},
"RetryWaitSec": {
"_meta": {
"range": "0-[int]::MaxValue",
"default": "10"
},
"value": null
},
"RawOutput": {
"value": null
},
"Inactive": {
"value": null
},
"NoRestart": {
"value": null
},
"NoSingleton": {
"value": null
},
"NoVersion": {
"value": null
},
"NoLogo": {
"value": null
},
"Test": {
"value": false
},
"SendMail": {
"_meta": {
"set": "Never,Always,OnError,OnSuccess,OnBackup,OnBackupError,OnBackupSuccess,OnRestore,OnRestoreError,OnRestoreSuccess",
"default": "Never"
},
"value": null
},
"SmtpServer": {
"value": "smtp.gmail.com"
},
"Port": {
"_meta": {
"range": "0-[int]::MaxValue",
"default": "0"
},
"value": 587
},
"From": {
"value": null
},
"To": {
"value": null
},
"NoSsl": {
"value": null
},
"CredentialFile": {
"value": null
},
"NoCredential": {
"value": null
},
"Anonymous": {
"value": null
},
"SendLogFile": {
"_meta": {
"set": "Never,OnError,OnSuccess,Always",
"default": "Never"
},
"value": "OnError"
},
"Logoff": {
"value": null
},
"Reboot": {
"value": null
},
"ForceReboot": {
"value": null
},
"ExcludeDirs": {
"_meta": {
"default": ["Diagnostics","Crash Reports","Updates","Logs"]
},
"value": null
},
"ExcludeFiles": {
"_meta": {
"default": ["*.bif"]
},
"value": null
},
"SpecialDirs": {
"_meta": {
"default": ["Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated"]
},
"value": null
},
"PlexServiceName": {
"_meta": {
"default": "^Plex"
},
"hasValue": false,
"value": null
},
"PlexServerFileName": {
"_meta": {
"default": "Plex Media Server.exe"
},
"value": null
},
"PlexServerPath": {
"value": null
},
"ArchiverOptionsCompress": {
"_meta": {
"comment": "The default options will always be applied. To include additional options, define them as an array.",
"default": ["-r","-y"]
},
"value": null
},
"ArchiverOptionsExpand": {
"_meta": {
"comment": "The default options will always be applied. To include additional options, define them as an array.",
"default": ["-aoa","-y"]
},
"value": null
}
}

Access to the cloud file is denied

hi,

i am having my backup folder on my OneDrive folder which is set to always keep offline, however after restoring my backup to a new machine, i starting getting the below error

C:\Users\xxxx\OneDrive\AppsBackups\Plex\20201115061503
Deleting old backup folder(s):
20201011061003
Access to the cloud file is denied
20201004061003
Access to the cloud file is denied
20200927061003
Access to the cloud file is denied
20200913061003
Access to the cloud file is denied
20200906061003

the end of the log seems to be running fine and successfully

Starting Plex Media Server process:
C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe
Script ended at:
2020.11.15 06:38:43.020
Script ran for (hr:min:sec.msec):
00:23:39.415
Script returned:
SUCCESS
Done.

Plex Update Service not automatically restarting

Running the script with command-line options interactively as follows:
.\PlexBackup.ps1 -Mode Backup -Type 7zip -PlexAppDataDir 'C:\Program Files (x86)\Plex\Plex Media Server' -BackupRootDir 'F:\Plex-Backup' -Log -ErrorLog -Verbose -Debug
Backup completes successfully, but the "Plex Update Service" does not automatically restart.

I'm 99.9% sure the issue is on line 1917 of PlexBackup.ps1 --
if ($services -and ($services.Count -le 0)) {
should instead read
if ($services -and ($services.Count -gt 0)) {

(In other words, if we stopped a service, the .Count should be >0, and thus we should enter the if and restart a service)

Editing that line as above and re-running the script restarts the Plex Update Service after execution correctly.

Error compressing Plex app data files. Error compressing folder 'Cache'. Exception calling "Write" with "3" argument(s): "Stream was too long." Stream was too long.

Hi there,

I have just installed the script and set everything up. On first backup run the backup seemed to finish really quick, so I went to the PlexBackup destination folder and opened the Backup.log. The script seems to have failed with the error of "Error compressing Plex app data files. Error compressing folder 'Cache'. Exception calling "Write" with "3" argument(s): "Stream was too long." Stream was too long."

I searched this on Google but didn't get any results.

My entire log is below, any ideas how to resolve this? Thanks

PlexBackup v2.0.6 (c) 2019-2021 Alek Davis
Script started at:
  09/08/2021 16:32:58
Operation mode:
  BACKUP
Backup type:
  DEFAULT
Plex version:
  1.24.2.5000
Log file:
  B:\PlexBackup\20210908163258\Backup.log
Stopping Plex services:
  Plex Update Service
Stopping Plex Media Server process:
  Plex Media Server.exe
Backup will be saved in:
  B:\PlexBackup\20210908163258
Creating task-specific subfolders in:
  B:\PlexBackup\20210908163258
    1
    2
    3
    4
Saving version:
  1.24.2.5000
to:
  B:\PlexBackup\20210908163258\Version.txt
Backing up special folders.
Moving:
  C:\Users\Chewie\AppData\Local\Plex Media Server\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
to:
  B:\PlexBackup\20210908163258\4\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
at:
  2021/09/08 16:33:02.604
Completed at:
  2021/09/08 16:33:02.700
Backing up Plex app data files in the root folder.
No files found in 'C:\Users\Chewie\AppData\Local\Plex Media Server' (it's okay).
Backing up Plex app data folders.
Archiving:
  C:\Users\Chewie\AppData\Local\Plex Media Server\Cache
to:
  B:\PlexBackup\20210908163258\2\Cache.zip
at:
  2021/09/08 16:33:03.210
Restoring special folders.
Copying:
  B:\PlexBackup\20210908163258\4\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
to:
  C:\Users\Chewie\AppData\Local\Plex Media Server\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
at:
  2021/09/08 16:39:42.219
Completed at:
  2021/09/08 16:39:42.274
Error compressing Plex app data files. Error compressing folder 'Cache'. Exception calling "Write" with "3" argument(s): "Stream was too long." Stream was too long.
Starting Plex services:
  Plex Update Service
Starting Plex Media Server:
  C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe
Script ended at:
  09/08/2021 16:39:42
Script ran for (hr:min:sec.msec):
  00:06:43.795
Script execution result:
  ERROR
Done.

error on Win8 machine

reporting this even though it should have no future impact, and it is a marginal usage case..
Setting up backup on a family member's windows 8.1 machine, I got this error :

Compress-Archive : The term 'Compress-Archive' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At C:\users\edited\Downloads\PlexBackup-master\PlexBackup.ps1:2259 char:17
+                 Compress-Archive -DestinationPath $zipFilePath -Update
+                 ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Compress-Archive:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

The error is pretty obvious, and the core reason is certainly the not-updated W8 OS.
Since I'll be using Robocopy, this is of no further consequence to me.
Perhaps some more elegant way of intercepting the missing Compress-Archive function is worth investigating...?

[not an issue] Thank you very much !

Hello !

I wanted to thank you for all the work you have done.

I was looking on Google for a viable solution to back up Plex but results may vary. I don't want to loose 5 years of datas.

I was able to save the database in 30 mins, thank you !

Script won't backup .bif files when using a 7-zip back up even when I remove .bif from the excluded files in the config file

Hi,

First let me say thanks for creating this script. It's been very useful. I'm running it the following way:

.\PlexBackup.ps1 -SevenZip -NoRestart -Log -ErrorLog -Keep 1

And in the config file I made the following edit:

"ExcludeFiles": {
        "_meta": {
            "default": ["*.bif"]
        },
        "value": [""]

I was hoping that was enough for the bif files to be included in the backup but after examining the backups I see they are not. Perhaps I'm doing something wrong? The config file basically the example config file with that modification.

I'm attaching the config file as well. (I had to change it from .json to .txt so it would let me attach it)

PlexBackup.ps1.txt

Restore Question

Hi Mr.Davis, sorry to reach you in this way

i’m running a plex server on a beelink sei8 mini pc, all is working fine except for BSOD like twice a month

Amazon.com: Beelink SEi8 Mini PC 8th Generation Intel i5-8279U Processor,(up to 4.1GHz) Windows 10 Pro Mini Computer with 8G DDR4 RAM/256GB M.2 NVME SSD,Supports 6MB Smart Cache,4K@30Hz Dual HDMI,WIFI6,BT5.0.: Computers & Accessories

with a plex lifetime pass

after many troubleshooting i found out i have a bad block on main ssd(disk c with os and plex files)
chkdsk state no problem on filesystem but there are 32kb of files on damaged sectors
no matter how many times i run chkdsk /f /r at boot

Damaged sector is on the primary boot partition on a first sight

even if i’m not completely sure the ssd is the problem, i have intention to replace it soon with another ssd nvme to exclude it’s the real problem.

Since the very beginning i’ve done backup with your script but never done a restore

The correct step to restore, just to be sure are:

Reinstall os from 0

-install everything i need other than plex and update os and driver, then:

i don’t know if i have first to download and install plex media server and login in or if i have first to restore plex files using the script with a command like this:

.\PlexBackup.ps1 -Mode Restore -BackupDirPath “\MYNAS\PlexBackup\20190101183015”

andf only after install plex media server and login again?

Which one is correct? It’s very important to me because i’ve very huge libraries, if i have to restart from 0 it’ll take 2 weeks at least working on it with 2 people

Obviously the media content drive will be placed in the same location as they were before, i mean drive letter and other stuff…
(Media content are something like 10 TB splitted on 4 external hdds WD, connected to mini pc by a powered HUB usb 3.0)

in restore mode i have to specify to use 7zip? if yes,which command i have to use?

Thanks for your answer

Best Regards

Cannot find Plex Media Server executable file

When running the script, I get the following error, but when running test path, it finds it.

PS C:\Users\Admin\Desktop\PlexBackup-master> .\PlexBackup.ps1
PlexBackup v1.5.10 (c) 2019 Alek Davis
Script started at:
  09/01/2019 09:15:19
Operation mode:
  BACKUP
Backup type:
  DEFAULT
Cannot find Plex Media Server executable file:
  C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe
PS C:\Users\Admin\Desktop\PlexBackup-master> Test-Path 'C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe'
True
PS C:\Users\Admin\Desktop\PlexBackup-master>

Log PMS version

It would be helpful to have the backup reflect the version of PMS at the time the backup was done. It would be even better if the backup version could be enforced during the restore operation.

Doesn't work with Powershell 6.2.3

When I run the backup using Powershell Core 6.2.3 I get the following error

LogException : The term 'Start-BitsTransfer' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At E:\MediaKitBackup\PlexBackup\PlexBackup.ps1:2275 char:17
+ LogException $_
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException

Backup.err.log

  • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,LogException

More "readable" folder name ?

Hello,

Is it possible to change the name of the folder to a something like this "29-12-2019_15-15-29" ?

I didn't found any option in the config file. Thank you ! :D

Must issue a STARTTLS command first when sending email

I am able to send an email through Gmail with the less secure app turned on. When I try to send an email with 2 steps verification turned on, I receive the following error message.

image

I use the code generated by Gmail as my new password in my credentials.xml. It does not give me an error message about the credentials.

confused about TempZipFileDir

If this is in the config file ( PlexBackup.ps1.json ) :

    "TempZipFileDir": {
        "hasValue": true,
        "value": null

then does the compression staging happen in windows TEMP folder ?

Scheduled backup fails

A backup that works fine when run interactively fails to run as a scheduled task. The email notification just says there was an error. There is no log folder or backup folder created. Most likely, it's due to NAS hosting the backup share being in the sleep mode.

Exclude folder don't work properly

Hi, i just started using your script
i've edited json config as follow
"ExcludeDirs": {
"_meta": {
"default": ["Diagnostics","Crash Reports","Updates","Logs","Cache"]
Basically "Cache" file is not needed as also stated by plex itself so i wanted to exclude it
adding Cache as you can see above

running this command as administrator in powershell...

PS C:\Users\manue\Downloads\PlexBackup-master\PlexBackup-master> .\PlexBackup.ps1 -Mode Backup -Type 7zip -LogLevel Debug -Log -ErrorLog -Keep 1

it keeps archive the cache folder

json and ps1 have the same name and are in the same folder

also, -loglevel debug don't show anything if i select -type 7zip
is it normal?
image

Feature request : Update backup

First of all : this might very well be the most elegantly written powershell script I've ever come across, personally or work-related.
Huge thumbs-up to @alekdavis !!

Being only human, we're never satisfied 🤦‍♂️
I took a backup yesterday, it took a looong time :

Script ran for (hr:min:sec.msec):
  02:54:49.962

The BackupRootDir was set to a local drive, so that wasn't the cause of the duration.
The size of the Plex folders is at cause.

TL;DR : would you consider adding an option to make a differential or incremental backup?
Perhaps the -update parameter to Compress-Archive might be useful ?

Skip Cache Folder

Plex's documentation (here) says that the cache folder can be skipped as it is simply regenerated the next time that Plex runs. Could the script skip backing up and/or restoring the Cache folder? It would save about 10 minutes of my backup time, and 6 gigs of storage for me.

PS - 7zip compression is terrific - did my first backup using that method today and it was great :-)

unable to run PlexBackup

Hi, i am not good with powershell, so what i did it as follows:

  1. downloaded the files
  2. Right clicked on PlexBackup, Run with PowerShell
  3. got the following message
    Execution Policy Change
    The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
    you to the security risks described in the about_Execution_Policies help topic at
    https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
    [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A

i selected Y
the powershell immediately closes and even if i re-open it again, it keeps closing

also, how do i setup the location, do i need to do anything? or it will automatically make the folders in the same location?

EDIT: i think i managed to run it, i was doing it all wrong, now i got the following error, which i think cuz i did not set up the backup directory, which i really do it what to do with

PS C:\Users\MAIN\OneDrive\AppsBackups\Plex> .\PlexBackup.ps1
PlexBackup v1.7.2 (c) 2020 Alek Davis
Script started at:
07/25/2020 12:22:05
Cannot initialize run-time configuration settings.
PS C:\Users\MAIN\OneDrive\AppsBackups\Plex>

i would like all the backups to be stored in C:\Users\MAIN\OneDrive\AppsBackups\Plex (it is my onedrive folder)

Allow 7-Zip Compression

Any thoughts on allowing the (optional?) use of 7zip as the compression method using the portable edition? In a few anecdotal tests, 7zip compressed my metadata folder in about 2/3 the time as the powershell compression currently used. It also resulted in a noticable-but-not-groundbreaking reduction in file size if that matters to others.

Set-ExecutionPolicy RemoteSigned is not recommended

Instead you can simply run as admin a .cmd file with the following line in it :

start powershell.exe -noprofile -executionpolicy bypass -file .\PlexBackup.ps1 -ConfigFile ".\PlexBackup.ps1.json"

This way you don't permanantly change security settings on you system.

Also you can adapt the following function to your code in order to require admin when the script start

Function RequireAdmin {
	If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
		Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PSCommandArgs" -Verb RunAs
		Exit
	}
}

Temp files not being deleted from Temp folder at end of process

Hi, first of all, THANK YOU for creating this tool. It's amazing and exactly what I needed. Can't thank you enough for sharing!

For the last month or so, I've noticed that the temporary files created in my Temp folder are not being deleted. So, they've started to accumulate and take up a huge amount of space on my drive. I just have to go in and manually delete them. My fear is I might forget to do this for an extended time and run out of disk space.

Any idea why this would be happening and how I could fix it?

Backup error due to missing registery key

I keep getting this error message:

reg : ERROR: The system was unable to find the specified registry key or value.
At D:\Backup\PlexBackup\PlexBackup.ps1:3115 char:13

I've looked in regedit the following key doesn't exist:

"HKU.DEFAULT\Software\Plex, Inc.\Plex Media Server

Is the key missing? And is there a way to remove this error?

Exception calling "Write" with "3" argument(s): "Stream was too long."

PS C:\WINDOWS\system32> C:\PlexBackup-1.6.2\PlexBackup.ps1
PlexBackup v1.6.2 (c) 2019 Alek Davis
Script started at:
  03/14/2020 21:56:20
Operation mode:
  BACKUP
Backup type:
  DEFAULT
Plex Media Server version (CURRENT):
  1.18.8.2527
Stopping Plex service(s):
  Plex Update Service
Stopping Plex Media Server process:
  Plex Media Server.exe
Ignoring script parameter:
  ExcludePlexAppDataFiles
Backup will be saved in:
  C:\PlexBackup-1.6.2\20200314215620
Creating backup folder:
  C:\PlexBackup-1.6.2\20200314215620
Creating task-specific subfolder(s) in:
  C:\PlexBackup-1.6.2\20200314215620
Backing up special subfolders.
Moving folder:
  C:\Users\Blake\AppData\Local\Plex Media Server\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
to:
  C:\PlexBackup-1.6.2\20200314215620\3\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
at:
  2020/03/14 21:56:21.437
Completed at:
  2020/03/14 21:56:21.468
Backing up Plex app data folders from:
  C:\Users\Blake\AppData\Local\Plex Media Server
to:
  C:\PlexBackup-1.6.2\20200314215620\1
Archiving:
  C:\Users\Blake\AppData\Local\Plex Media Server\Cache
to temp file:
  C:\Users\Blake\AppData\Local\Temp\PlexBackup-6fdf4a99-c09f-4548-b21c-246276f21fb0.zip
at:
  2020/03/14 21:56:21.533
LogException : Exception calling "Write" with "3" argument(s): "Stream was too long."
At C:\PlexBackup-1.6.2\PlexBackup.ps1:2266 char:13
+             LogException $_
+             ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,LogException
 
Restoring special subfolders.
Copying folder:
  C:\PlexBackup-1.6.2\20200314215620\3\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
to:
  C:\Users\Blake\AppData\Local\Plex Media Server\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
at:
  2020/03/14 22:24:41.475
Completed at:
  2020/03/14 22:24:41.572
Starting Plex service(s):
  Plex Update Service
Starting Plex Media Server process:
  C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe
Script ended at:
  2020/03/14 22:24:42.308
Script ran for (hr:min:sec.msec):
  00:28:21.911
Script returned:
  ERROR
Measure-Object : The property "Length" cannot be found in the input for any objects.
At C:\PlexBackup-1.6.2\PlexBackup.ps1:3522 char:55
+ ... ldItem -Recurse $BackupDirPath | Measure-Object -Property Length -Sum
+                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Measure-Object], PSArgumentException
    + FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand

Whenever I run the script with the default settings, I get this output. Please assist!

PS C:\WINDOWS\system32> Get-Host | Select-Object Version

Version      
-------      
5.1.18362.628

Restore Error

Hello,

I restored a backup, all seems ok but I had an error, sorry It's in French :
L'opération a réussi. => The operation is a success.

reg : L'opération a réussi.
Au caractère D:\PlexBackup-master\PlexBackup.ps1:2692 : 13
reg import $backupRegKeyFilePath *>&1 | Out-Null
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (L'opération a réussi.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

Is that bad ? Thank you

Not able to run it at all...

So I've been backing up plex manually for ages, and ended up running across this and thought it'd be nice to be able to set this up and use it instead as it would be so much nicer/quicker to do this all automatically, but I'm running into issues right now.

First issue:
I'm trying to use the whole config file option ./PlexBackup.ps1 -ConfigFile "C:\Users\JourneyOver\Desktop\Projects\PlexBackup\PlexBackup.json", but each time I try to specify the config file location upon running the script it always seems to throw an error.

PlexBackup v1.3.3 (c) 2019 Alek Davis
Script started at:
  02/09/2019 22:09:22
Config file:
  C:\Users\JourneyOver\Desktop\Projects\PlexBackup\PlexBackup.json
not found.
Cannot initialize run-time configuration settings.

The thing is, is the file does exist so I do not know why it's throwing the error that it's not found..

I've tried moving everything to a different drive where all my other plex stuff is at and I end up running into a whole different issue as well...

D:\Plex Stuff\PlexBackup\PlexBackup.ps1 : Cannot validate argument on parameter 'Mode'. The argument "Stuff\PlexBackup\PlexBackup.json" does
not belong to the set "Backup,Continue,Restore" specified by the ValidateSet attribute. Supply an argument that is in the set and then try
the command again.
At line:1 char:38
+ ./PlexBackup.ps1 -ConfigFile D:\Plex Stuff\PlexBackup\PlexBackup.json
+                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [PlexBackup.ps1], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,PlexBackup.ps1

For some reason or another it seems to completely be cutting out the D:\Plex bit from the path, even though I surround it in quotes ./PlexBackup.ps1 -ConfigFile "D:\Plex Stuff\PlexBackup\PlexBackup.json"..

If I try without supplying a custom config file ./PlexBackup.ps1, it just ends up throwing a completely different error in the process..

PlexBackup v1.3.3 (c) 2019 Alek Davis
Script started at:
  02/09/2019 22:16:26
The variable cannot be validated because the value False is not a valid value for the SendMail variable.
At C:\Users\JourneyOver\Desktop\Projects\PlexBackup\PlexBackup.ps1:2685 char:9
+         $SendMail = $false
+         ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ValidateSetFailure

So I am at a complete loss on what the hell is going on with this script..Hopefully you can help out, since you are the one who made this script after all, and I'd really like to use it.

One Occurrence of "retrun" Causes Error

I chose to remove the option to not compress special folders and encountered an error:

WriteDebug "Entered BackupSpecialFolders."

if (!($specialDirs) -or
     ($specialDirs.Count -eq 0)) {
    **retrun** $true
}

Plex doesn't start after backup

Hello,
First of all, great script, does all the backups properly with no problems, great job.

Now to my issue:
After the backup (using robocopy because incremental backups are fast) and script returned SUCCESS it tries to start PMS but "fails". The PMS icon appears in the notification area for a little sometimes during a minute or so, then closes i have to go in and restart it manually. Any ideas?

Also, is there a way to auto close the script on success? It stays running even after the backup has ended.

Thanks for your time.

Exclude file types

Would be great to exclude file types, most notably .bif files (video preview thumbnails). If they are enabled, they are mingled in with the Media folder, and consume about 30GB of space on my system. They can be regenerated if needed by Plex.

Error: ZipArchiveHelper : Could not find a part of the path

Hello,

I keep getting the following error in the middle of the backup:
ZipArchiveHelper : Could not find a part of the path 'C:\Users\user\AppData\Local\Plex Media Server\Plex Media Server\Metadata\Albums\1\8f8f782d3066db7ea87a6b0573e065a1e2ad0e9.bundle\Contents\com.plexapp.agents.lyricfind\tracks\1fa14e37789fc5b5f6b5fa1fbfd0fe94eaec21ba\lyrics\c32a0f31a41aa2de43eb84799b25761a29af2d52'.

I can't figure it out.
Thank you.

Folders unavailable after Plex server restart (WIN10 Home)

Hi Alek,
Backup script works just fine but after a (successful) restart of Plex Server instance, all remote folders located on a Synology NAS mapped drives, content is showing as unavailable. Manual restart of Plex solve the issue. Strange because the scheduled task is configured to run as the (only) account on the Win10 Home server as described in your help section. The Plex Server was first configured to run with the unique Microsoft account, I changed to run as local account but same issue.
Thank you, Francisco

Initialization error.

Hi.
Just trying to get yr script going today.

I get this error on running it:

PlexBackup Init Error

I think my troubles may be a restriction caused by the user that runs PMS not being a local administrator and the need to run the ps1 script as an admin. May be?

Restore Operation Taking Ages

@alekdavis thank you for this amazing tool! When I get more time to play around with it I will definitely try to contribute!

I'm in the middle of a PMS migration from one Win10 Desktop (Source) to a net new one running Win10 as well (Destination). PMS on both systems are the same version and both systems have 7-Zip installed.

I placed the Backup Dir for the Source as a NAS in the config file then ported the config file over to the Destination system with zero changes.

I then proceeded to run .\PlexBackup.ps1 -Restore and it starts all well and good but then hangs for ages on unpacking the Codec 7z Archive. Have you seen this before? How long does a restore normally take?

Full Log:

PS C:\Users\USERNAME\Documents\GitHub\PlexBackup> .\PlexBackup.ps1 -Restore                                                PlexBackup v1.7.0 (c) 2020 Alek Davis                                                                                   Script started at:                                                                                                        06/24/2020 16:09:41
Validating log file folder:
  \\NAS\NASPlexMedia\PlexPowershellBackups\20200624150406
Operation mode:
  RESTORE
Backup type:
  7ZIP
Log file:
  \\NAS\NASPlexMedia\PlexPowershellBackups\20200624150406\Restore.log
Error log file:
  \\NAS\NASPlexMedia\PlexPowershellBackups\20200624150406\Restore.err.log
Plex Media Server version (CURRENT):
  1.19.4.2935
Plex Media Server version (BACKUP):
  1.19.4.2935
Stopping Plex Media Server process:
  Plex Media Server.exe
Restoring Plex app data folders from:
  \\NAS\NASPlexMedia\PlexPowershellBackups\20200624150406\2
Copying backup archive file:
  \\NAS\NASPlexMedia\PlexPowershellBackups\20200624150406\2\Codecs.7z
to a temp zip file:
  C:\Users\USERNAME\AppData\Local\Temp\PlexBackup-6e61f887-4e35-4509-a8da-55a4ecb701e5.7z
at:
  2020/06/24 16:09:47.368
Completed at:
  2020/06/24 16:09:51.859
Restoring Plex app data from:
  C:\Users\USERNAME\AppData\Local\Temp\PlexBackup-6e61f887-4e35-4509-a8da-55a4ecb701e5.7z
to Plex app data folder:
  C:\Users\USERNAME\AppData\Local\Plex Media Server\Codecs
at:
  2020/06/24 16:09:51.903

7z parameters for performance?

Is there a way your script could pass parameters to 7-zip to increase performance? I have a Plex system with 28 cores, 384GB of RAM, and NVME SSD storage - a backup operation currently uses ~5% CPU and about 5GB of RAM and takes about 90 mins to complete. It appears that 7z has some switches for memory usage and multithreading. Have you considered allowing usage of these parameters?

https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm

What is SubDirFiles?

Quick question, but what is Sub Folder 1 (SubDirFiles) supposed to include? I just ran my first backup and noticed it was empty. I'm assuming it's looking for files in the root "Plex Media Server" folder as opposed to all the folders that get backed up in Sub Folder 2 (SubDirFolders), but am curious what those would typically be since I don't seem to have any.

Regardless, thank you for writing this awesome script! The Readme and code itself is wonderfully written and commented. Put my little script to shame!

Cannot save Plex Media Server version

Asked me to create a new issue for anything else that needed to be looked at and really the only thing left now that I can spot after you fixed the configfile stuff in 1.5.7 is the whole Plex media server version information not being able to be saved in a .txt file.

whenever I run the script when it gets to the saving of the Plex media server version information it always seems to end up outputting:

Plex Media Server version (CURRENT):
  1.15.6.1079
Cannot save Plex Media Server version:
  1.15.6.1079
to:
  H:\Ketarin\ketarin-files\installers\Backups\PMS\20190518114319\version.txt
Could not find a part of the path 'H:\Ketarin\ketarin-files\installers\Backups\PMS\20190518114319\version.txt'.

I dunno where exactly it's failing at in the script, but it seems to never make the version.txt file.

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.