alekdavis/PlexBackup

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

a3m5 opened this issue · 10 comments

a3m5 commented

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?

@a3m5 : I do not have time to check it now, but I will take a look when I get a chance (maybe in a few weeks). Could you tell me with which switches you are running the backup job?

a3m5 commented

Yeah man, totally get it - I appreciate the quick response on its own.

You'll have to forgive me, I'm not totally sure what you mean by switches. These are the arguments I'm using - is that what you're looking for?

-WindowStyle Hidden -ExecutionPolicy Bypass "C:\PlexBackup-master\PlexBackup-master\PlexBackup.ps1"

What type of backup are you using? 7-zip? Default? Robocopy? Basically whatever is in the configuration (JSON) file.

a3m5 commented

7zip. Here is everything I customized in the JSON file:

"Type": {
"_meta": {
"set": ",7zip,Robocopy",
"default": ""
},
"value": "7zip"
},
"PlexAppDataDir": {
"_meta": {
"default": "$env:LOCALAPPDATA\Plex Media Server"
},
"value": "P:\Plexdata\Plex Media Server"
},
"BackupRootDir": {
"_meta": {
"default": "$PSScriptRoot"
},
"value": "P:\PlexBackup"
},
"BackupDir": {
"_meta": {
"default": null
},
"value": null
},
"TempDir": {
"_meta": {
"default": "$env:TEMP"
},
"hasValue": true,
"value": "P:\Plex Backup TEMP"
},

@a3m5 Thanks. I'll take a look (most likely, in a few weeks).

@a3m5 Also, could you try running the script with the -Verbose flag (on command line)? The verbose log should show messages when temp files get deleted.

a3m5 commented

Hi, here's the full verbose log. I can confirm the temp files were not deleted still.

PS C:\PlexBackup-master\PlexBackup-master> .\PlexBackup.ps1 -verbose
VERBOSE: Importing module 'ScriptVersion'.
VERBOSE: Loading module from path
'C:\Users\XXX\Documents\WindowsPowerShell\Modules\ScriptVersion\1.0.0\ScriptVersion.psd1'.
VERBOSE: Removing the imported "Get-ScriptVersion" function.
VERBOSE: Populating RepositorySourceLocation property for module ScriptVersion.
VERBOSE: Loading module from path
'C:\Users\XXX\Documents\WindowsPowerShell\Modules\ScriptVersion\1.0.0\ScriptVersion.psm1'.
VERBOSE: Importing function 'Get-ScriptVersion'.
VERBOSE: Importing module 'ConfigFile'.
VERBOSE: Loading module from path
'C:\Users\XXX\Documents\WindowsPowerShell\Modules\ConfigFile\1.1.0\ConfigFile.psd1'.
VERBOSE: Removing the imported "Import-ConfigFile" function.
VERBOSE: Populating RepositorySourceLocation property for module ConfigFile.
VERBOSE: Loading module from path
'C:\Users\XXX\Documents\WindowsPowerShell\Modules\ConfigFile\1.1.0\ConfigFile.psm1'.
VERBOSE: Importing function 'Import-ConfigFile'.
VERBOSE: Importing module 'StreamLogging'.
VERBOSE: Loading module from path
'C:\Users\XXX\Documents\WindowsPowerShell\Modules\StreamLogging\1.2.1\StreamLogging.psd1'.
VERBOSE: Removing the imported "Format-LogFilePath" function.
VERBOSE: Removing the imported "Get-LoggingConfig" function.
VERBOSE: Removing the imported "Start-Logging" function.
VERBOSE: Removing the imported "Stop-Logging" function.
VERBOSE: Removing the imported "Test-LoggingStarted" function.
VERBOSE: Removing the imported "Write-Log" function.
VERBOSE: Removing the imported "Write-LogDebug" function.
VERBOSE: Removing the imported "Write-LogError" function.
VERBOSE: Removing the imported "Write-LogException" function.
VERBOSE: Removing the imported "Write-LogInfo" function.
VERBOSE: Removing the imported "Write-LogWarning" function.
VERBOSE: Populating RepositorySourceLocation property for module StreamLogging.
VERBOSE: Loading module from path
'C:\Users\XXX\Documents\WindowsPowerShell\Modules\StreamLogging\1.2.1\StreamLogging.psm1'.
VERBOSE: Importing function 'Format-LogFilePath'.
VERBOSE: Importing function 'Get-LoggingConfig'.
VERBOSE: Importing function 'Start-Logging'.
VERBOSE: Importing function 'Stop-Logging'.
VERBOSE: Importing function 'Test-LoggingStarted'.
VERBOSE: Importing function 'Write-Log'.
VERBOSE: Importing function 'Write-LogDebug'.
VERBOSE: Importing function 'Write-LogError'.
VERBOSE: Importing function 'Write-LogException'.
VERBOSE: Importing function 'Write-LogInfo'.
VERBOSE: Importing function 'Write-LogWarning'.
VERBOSE: Importing module 'SingleInstance'.
VERBOSE: Loading module from path
'C:\Users\XXX\Documents\WindowsPowerShell\Modules\SingleInstance\1.1.0\SingleInstance.psd1'.
VERBOSE: Removing the imported "Enter-SingleInstance" function. VERBOSE: Removing the imported "Exit-SingleInstance" function. VERBOSE: Removing the imported "Get-ScriptPath" function. VERBOSE: Populating RepositorySourceLocation property for module SingleInstance. VERBOSE: Loading module from path 'C:\Users\XXX\Documents\WindowsPowerShell\Modules\SingleInstance\1.1.0\SingleInstance.psm1'. VERBOSE: Importing function 'Enter-SingleInstance'. VERBOSE: Importing function 'Exit-SingleInstance'. VERBOSE: Importing function 'Get-ScriptPath'. VERBOSE: Importing settings from default configuration file (if any). VERBOSE: Loading config file 'C:\PlexBackup-master\PlexBackup-master\PlexBackup.ps1.json'. VERBOSE: Converting config file settings into a JSON object.
VERBOSE: Setting variable(s):
VERBOSE: -Type '7zip'
VERBOSE: -PlexAppDataDir 'P:\Plexdata\Plex Media Server'
VERBOSE: -BackupRootDir 'P:\PlexBackup'
VERBOSE: -TempDir 'P:\Plex Backup TEMP'
VERBOSE: -Log 'True'
VERBOSE: -SmtpServer 'smtp.gmail.com' VERBOSE: -Port '587' VERBOSE: -SendLogFile 'OnError' VERBOSE: Done setting 8 variable(s) from the config file. VERBOSE: Validating script execution mode. VERBOSE: Validating backup type. VERBOSE: Waking up 'P:\PlexBackup'. VERBOSE: Setting Plex Media Server path for version checking to 'C:\Program Files (x86)\Plex\Plex Media Server\Plex
Media Server.exe'.
VERBOSE: Reading Plex Media Server version from 'C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe'.
VERBOSE: Plex Media Server version: '1.22.1.4228'.
VERBOSE: Email notification will not be sent.
VERBOSE: Version validation skipped during backup.
VERBOSE: Making sure the script is not already running.
VERBOSE: Creating single-instance mutex 'C:/PlexBackup-master/PlexBackup-master/PlexBackup.ps1'.
VERBOSE: Setting log file to 'P:\PlexBackup\20210330102841\Backup.log'.
VERBOSE: Not using error log file.
VERBOSE: Initializing logging.
VERBOSE: Starting stream logging.
VERBOSE: Setting stream logging properties.
VERBOSE: Config file 'C:\PlexBackup-master\PlexBackup-master\PlexBackup.ps1.StreamLogging.json' is not found.
VERBOSE: Creating directory 'P:\PlexBackup\20210330102841'.
VERBOSE: Creating file 'P:\PlexBackup\20210330102841\Backup.log'.
VERBOSE: No Plex services detected running.
VERBOSE: Trying to stop Plex Media Server process gracefully.
VERBOSE: Checking if Plex Media Server process stopped gracefully.
VERBOSE: Waking up 'P:\PlexBackup'.
VERBOSE: Overwriting 'P:\PlexBackup\20210330102841\Version.txt'.
VERBOSE: Excluding file types: *.bif Transcode
VERBOSE: Deleting 'P:\Plex Backup TEMP\Plex1088107e-3466-4e22-b73d-78a190953d75.7z'.
VERBOSE: Excluding file types: *.bif Transcode
VERBOSE: Deleting 'P:\Plex Backup TEMP\Plex96bf9691-3a4c-47d1-af44-743de394f3dc.7z'.
VERBOSE: Excluding file types: *.bif Transcode
VERBOSE: Deleting 'P:\Plex Backup TEMP\Plex458fb45b-a275-4891-bbf9-a3710dd7122a.7z'.
VERBOSE: Excluding file types: *.bif Transcode
VERBOSE: Deleting 'P:\Plex Backup TEMP\Plex67873de6-4bbe-4da3-8483-9fc7f2d20422.7z'.
VERBOSE: Excluding file types: *.bif Transcode
VERBOSE: Deleting 'P:\Plex Backup TEMP\Plex3bb88b21-c7ca-4138-821d-d653510a5d88.7z'.
VERBOSE: Excluding file types: *.bif Transcode
VERBOSE: Deleting 'P:\Plex Backup TEMP\Plexb477ebd6-5cda-4a78-bf0b-96197df20b06.7z'.
VERBOSE: Checking if Plex Media Server is already running.
VERBOSE: Plex Media Server is not running.
VERBOSE: Releasing single-instance mutex.
VERBOSE: Uninitializing logging.
VERBOSE: Stopping stream logging.
VERBOSE: Resetting stream logging properties.
VERBOSE: Closing log file stream.
VERBOSE: The end.

@a3m5 Thanks. I checked code and it does seem like this is a bug. I updated it, so please get the latest version of the PlexBackup.ps1 file and see if it fixes the problem.

a3m5 commented

Yes, that fixed it! That's amazing. Thank you for the quick fix - and really, thank you for creating and sharing this. I'm sure this is a hobby project that you decided to share with all of us, so from one of your users and fans, THANK YOU!

@a3m5 Sweet. Thanks for reporting this.