Now we have a RV I wanted the pi to copy media files over when it is on the network. I have a share for our DVR where the media files are placed (HD Homerun + Emby) and wanted to copy certain TV shows over automatically when the RV is home and I put it on the network.
Now I can go down the BASH scripting route but I do not know that space very well. However I do know the PowerShell space well so installing it made sense. Following the instructions Installing PowerShell on Linux I made a cheat sheet so it is faster if I have to rebuild t a later time.
Now we have PowerShell installed we can get to the script, this will be run every hour via cron. You may have to update some of the paths. It assume that the remote server is mounted under
/mnt/tv and the local drive is under
/mnt/videos/tv. You will also have to update the IP address of the server that has the DVR files, replace
0.0.0.0 with your server IP.
For this to work make a file called
test.txt in the remote mount share so the script can validate access. Then in the root folders you want to copy put a empty file called
.rcopy. In the tv share I have a folder for every show and then folder under it for each season where the DRV has recorded. Emby has automation to make this so it is tidy and I can delete a season simply when I have watched it.
I use cron to schedule this to run once a hour, if the PI can see my home server then it will start the copy if not it will just skip the copy and exit. If the copy takes more than a hour having two instances running could be problematic so I drop a file int he pi profile directory. If it is there the process exits, if not it proceeds. Also handy to disable the copy process if you want to run manually without having to edit cron.
$serverIp = "0.0.0.0"
If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you!