home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Support
General Support
Move recordings to NAS after X days?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="batsi" data-source="post: 1075695" data-attributes="member: 75463"><p>Hi Statts,</p><p></p><p>I have a working solution for, errr, yeah probably almost two years, if I have a look at the dates of my postings in this thread. Some may judge it as very unsophisticated, but for me it's fine.</p><p></p><p>These are the steps, how I set it up:</p><ol> <li data-xf-list-type="ol">Set up a user on the file server with same username/password as the user running MediaPortal on the MP PC<br /> (maybe you want to or have already set up Autologon on the MP PC for that user)<br /> </li> <li data-xf-list-type="ol">Set up a CIFS/SMB file share on the server and grant read/write access to that user</li> <li data-xf-list-type="ol">Change the user, the TVservices on the MP PC runs from SYSTEM to that user<br /> (needed for the TVService having write access on the file share)</li> <li data-xf-list-type="ol">In the MP recording folder on the MP PC make a symbolic link to the UNC path of the server<br /> ("<span style="font-family: 'Courier New'">mklink /d D:\Recordings\Server \\server\share</span>" from elevated cmd)</li> <li data-xf-list-type="ol">Create a batch file on the MP PC with the content below<br /> </li> <li data-xf-list-type="ol">Create a Scheduled Task that calls that batch every 15 mins<br /> (daily task, check "repeat every" with 15 mins for 1 day)</li> </ol><p>Every time the batch is called by the scheduler, it first checks if another instance is already running, and skips if it is. If then the drive space on the source drive is less than configured in $MinFreeGB it copies the files and changes the entries in the MySQL database.</p><p></p><p>This is in productive use at my MediaPortal and works very reliable. It works completely in background, and you won't recognize a difference if the recording is local or on the server. I have never had the case, that I wanted to access a recroding while it was copying.</p><p></p><p>I hope, this helps you (or anyone else)</p><p></p><p>Regards</p><p>Bastian</p><p></p><p>[CODE=WinBatch]@echo off</p><p>SetLocal EnableDelayedExpansion</p><p></p><p>set SOURCE=D:\Recordings</p><p>set DEST=D:\Recordings\Server</p><p></p><p>set MinFreeGB=40</p><p></p><p>set logfile=D:\%~n0.log</p><p></p><p>set mysqlDB=mptvdb</p><p>set mysqlUser=root</p><p>set mysqlPass=MediaPortal</p><p>set mysqlEXE="%ProgramFiles%\MySQL\MySQL Server 5.1\bin\mysql.exe"</p><p></p><p>set runPID=%tmp%\%~n0.pid</p><p></p><p>if exist %runPID% goto:checkprog</p><p>echo.> %runPID%</p><p></p><p>call:checkfree %SOURCE%</p><p>if %freespace% GTR %MinFreeGB% goto:end</p><p></p><p>for /f "tokens=*" %%i in ('dir /b /od %SOURCE%\*.ts') do (</p><p> call:log "Starting move - %%i"</p><p> call:run "%SOURCE%\%%i">>%logfile%</p><p> call:log " Finished."</p><p> goto:end</p><p>)</p><p></p><p>:run</p><p>robocopy /MOV /R:0 /NFL /NDL /NP /NJH /NJS "%SOURCE%" "%DEST%" "%~n1.*"</p><p>%mysqlEXE% -u%mysqlUser% -p%mysqlPass% %mysqlDB% --default-character-set=latin1 -e "update `recording` set `fileName` = '%DEST:\=\\%\\%~nx1' where `fileName` = '%SOURCE:\=\\%\\%~nx1'"</p><p>goto:eof</p><p></p><p>:checkfree</p><p>for /f "tokens=2" %%s in ('wmic volume get DriveLetter^, FreeSpace ^| findstr "^%~d1"') do set freespace=%%s</p><p>set freespace=!freespace:~0,-9!</p><p>goto:eof</p><p></p><p>:checkprog</p><p>tasklist | findstr /i "robocopy.exe" 1>NUL 2>&1 || erase %runPID%</p><p>goto:eof</p><p></p><p>:log</p><p>echo %DATE% %TIME% - %~1>>%logfile%</p><p>goto:eof</p><p></p><p>:end</p><p>erase %runPID%</p><p>goto:eof[/CODE]</p></blockquote><p></p>
[QUOTE="batsi, post: 1075695, member: 75463"] Hi Statts, I have a working solution for, errr, yeah probably almost two years, if I have a look at the dates of my postings in this thread. Some may judge it as very unsophisticated, but for me it's fine. These are the steps, how I set it up: [LIST=1] [*]Set up a user on the file server with same username/password as the user running MediaPortal on the MP PC (maybe you want to or have already set up Autologon on the MP PC for that user) [*]Set up a CIFS/SMB file share on the server and grant read/write access to that user [*]Change the user, the TVservices on the MP PC runs from SYSTEM to that user (needed for the TVService having write access on the file share) [*]In the MP recording folder on the MP PC make a symbolic link to the UNC path of the server ("[FONT=Courier New]mklink /d D:\Recordings\Server \\server\share[/FONT]" from elevated cmd) [*]Create a batch file on the MP PC with the content below [*]Create a Scheduled Task that calls that batch every 15 mins (daily task, check "repeat every" with 15 mins for 1 day) [/LIST] Every time the batch is called by the scheduler, it first checks if another instance is already running, and skips if it is. If then the drive space on the source drive is less than configured in $MinFreeGB it copies the files and changes the entries in the MySQL database. This is in productive use at my MediaPortal and works very reliable. It works completely in background, and you won't recognize a difference if the recording is local or on the server. I have never had the case, that I wanted to access a recroding while it was copying. I hope, this helps you (or anyone else) Regards Bastian [CODE=WinBatch]@echo off SetLocal EnableDelayedExpansion set SOURCE=D:\Recordings set DEST=D:\Recordings\Server set MinFreeGB=40 set logfile=D:\%~n0.log set mysqlDB=mptvdb set mysqlUser=root set mysqlPass=MediaPortal set mysqlEXE="%ProgramFiles%\MySQL\MySQL Server 5.1\bin\mysql.exe" set runPID=%tmp%\%~n0.pid if exist %runPID% goto:checkprog echo.> %runPID% call:checkfree %SOURCE% if %freespace% GTR %MinFreeGB% goto:end for /f "tokens=*" %%i in ('dir /b /od %SOURCE%\*.ts') do ( call:log "Starting move - %%i" call:run "%SOURCE%\%%i">>%logfile% call:log " Finished." goto:end ) :run robocopy /MOV /R:0 /NFL /NDL /NP /NJH /NJS "%SOURCE%" "%DEST%" "%~n1.*" %mysqlEXE% -u%mysqlUser% -p%mysqlPass% %mysqlDB% --default-character-set=latin1 -e "update `recording` set `fileName` = '%DEST:\=\\%\\%~nx1' where `fileName` = '%SOURCE:\=\\%\\%~nx1'" goto:eof :checkfree for /f "tokens=2" %%s in ('wmic volume get DriveLetter^, FreeSpace ^| findstr "^%~d1"') do set freespace=%%s set freespace=!freespace:~0,-9! goto:eof :checkprog tasklist | findstr /i "robocopy.exe" 1>NUL 2>&1 || erase %runPID% goto:eof :log echo %DATE% %TIME% - %~1>>%logfile% goto:eof :end erase %runPID% goto:eof[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Support
General Support
Move recordings to NAS after X days?
Contact us
RSS
Top
Bottom