A long time ago, I was talking about how to separate the DVR metadata from the recordings.
As I left it, I was using symlinks on my BeeHive (ChannelsDVR machine) to point the C:\DVR\TV\ and C:\DVR\Movies\ directories over to file shares on ZULU (my Windows Server 2022). That worked fine most of the time, but resulted in duplicate listings of all recordings, and also made recordings fail if the connection to the server was temporarily borked.
A few months ago, I dropped the symlinks, letting BeeHive record directly to its internal SSD. Then I set up a Task Schedule task to move recordings to ZULU using RoboCopy. This was great, except for the fact that if the recording was in-process... for some reason ChannelsDVR didn't have the file opened in exclusive mode, so the move succeeded, but the recording was truncated (usually at 6 minutes in).
Today, I saw a batch file example from @Edwin_Perez over on the OliveTin scripts thread, and saw how to check if the DVR is recording... so my batch file has been updated and works SO MUCH BETTER now.
Save this file as MigrateRecordings.cmd in the ChannelsDVR data directory (I use C:\DVR) and then setup a Windows Task Scheduler to start it up during login and it will just stay running in a loop. I've got it setup to take the server name as a argument (and defaulting to \\ZULU if not supplied).
CD /d "%~dp0"
if [%1] NEQ [] if [%server%] EQU [] set server="%~1"
if [%server%] EQU [] set server=\\ZULU
set migrationneeded=yes
:loop
REM cls
title "Migrate Recordings"
curl.exe "http://127.0.0.1:8089/dvr" | findstr /I /C:"Recording"
set recording=%ERRORLEVEL%
if %recording% EQU 0 set migrationneeded=yes
if %recording% NEQ 0 if %migrationneeded% EQU yes call :migrate
:resume
if %recording% NEQ 0 set migrationneeded=no
if %recording% EQU 0 timeout /T 300
if %recording% NEQ 0 timeout /T 3600
goto :loop
:migrate
robocopy %~dp0TV %server%\TV\ /XF ReadMe.txt /MOV /S /J /COPY:DT /DCOPY:DT /XX /IM /IT /FP /MINAGE:0 /R:3 /W:5 /TEE /NJH /UNILOG+:"%~dp0Logs\Migrate\TV.log" /UNICODE
robocopy %~dp0Movies %server%\Movies\ /XF ReadMe.txt /MOV /S /J /COPY:DT /DCOPY:DT /XX /IM /IT /FP /MINAGE:0 /R:3 /W:5 /TEE /NJH /UNILOG+:"%~dp0Logs\Migrate\Movies.log" /UNICODE
Here's the setup in Task Scheduler:
- Task definition
- Triggers
- Daily schedule to ensure it restarts at 05:00
- Ensures it runs at machine startup
- Actions (Start a Program)
- MigrateFiles.cmd in C:\DVR with server name \\ZULU
- Leave Conditions at defaults (since the DVR machine should be on AC at all times)
- Settings to ensure it auto-restarts
This likely could be improve a bunch (perhaps with better busy detection), but at least this will stop the truncated recordings