Rsync via Cron: Partially Missing Files Pulling Local Media Server Torrent Directory
In this article, we will discuss how to use the rsync command in a Cron job to keep a local media server's TV show directory in sync with a torrent server. This will ensure that the local media server has all the latest TV shows and that any missing files are pulled from the torrent server.
Prerequisites
Before we begin, make sure you have the following:
- A public media server running Debian 11 (
server1) - A private media server running Debian 12 (
server2) - Both servers should have the
rsyncpackage installed
Setting up the Cron Job
To set up the Cron job, we first need to log in to server1 and open the Cron table with the following command:
crontab -eAdd the following line to the Cron table to run the rsync command every hour:
0 * * * * rsync -avz --delete /home/TV/ server2:/home/TV/This will run the rsync command with the following options:
-a: archive mode, which preserves file permissions, ownership, and timestamps-v: verbose mode, which shows the progress of the transfer-z: compress mode, which compresses the data during transfer to save bandwidth--delete: delete files on the destination that don't exist on the source
Partially Missing Files
If some files are missing on server1 but present on server2, we can use the --update option with rsync to update the missing files on server1 with the ones on server2.
0 * * * * rsync -avz --delete --update /home/TV/ server2:/home/TV/Pulling from Torrent Directory
If the TV shows on server2 are stored in a torrent directory, we can modify the rsync command to pull the files from the torrent directory instead of the main TV directory.
0 * * * * rsync -avz --delete --update server2:/home/TV/torrent/ /home/TV/In this article, we have discussed how to use the rsync command in a Cron job to keep a local media server's TV show directory in sync with a torrent server. We have also covered how to handle partially missing files and how to pull files from a torrent directory. By following the steps outlined in this article, you can ensure that your local media server has all the latest TV shows and that any missing files are pulled from the torrent server.