Move finished *rTorrent* (rutorrent) torrents to GDrive via rclone on finish?

Didn't find any viable solution on how to do exactly that. I want it to execute

rclone move the/torrent/file myremote:torrent/file

on finished torrents and have it remove the torrent and the file(s) (if not already) from the seedbox completely.

How would i go about doing that? Something in .rtorrent.rc would work best, to not have rclone running literally every 5 minutes with cron, and only be running whenever a torrent is actually finished?

The absolutely best method is to use a torrent-client that has support for a "temporary download location". many clients have this - like Qbittorrent which I use. EDIT: a cursory google search indicates rtorrent may have a feature like this, so please investigate that.

That allows you to solve it natively in the application as you can just have the torrent client do the move itself (via mount) to the Gdrive when they are done.

Without using this it's going to be a little janky either way because rclone can't know when the torrent is done - and also transferring half-finished torrents produce useless junk and probably would make errors in the torrent client.

Or if the torrent-client is remote and does not see the Gdrive directly, then it can at least move the torrents to a "finished" folder where you can have a simple script pick it up and run the move command without causing any problems with half-finished files. If you just make your script check the folder for files before calling rclone then it's a very trivial check to run, so you can test as often as you want.

Here is a really basic script that demonstrates some of the fundamentals of that.
I don't claim to be good at bash scripting, but maybe you can at least find it useful to see how to prevent multiple operations overlapping (lockfile) and do a simple check on a folder to see if it is empty or not. The idea is you'd run this as a recurring cron task on some appropriate timer.


#Lock the file so only one of these scripts can run at once.
lockfile -r 0 /tmp/uploadscript.lock || exit 1

##loop until we detect files in the upload folder, then perform rclone upload command and exit
for (( ; ; ))
if [ -z "$(ls -A /path/to/your/gdrive/mount)" ]; then
   echo "Empty" && sleep 900
   echo "Not Empty" && PUT YOUR FULL RCLONE UPLOAD COMMAND HERE && rm -f /tmp/uploadscript.lock && exit

#sleep 900 => retry every 15 minutes if the folder was empty


#You MAY want to change this, but it should be fine as-is on a standard setup:

just change the command from sending email to running rclone.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.