Skip to content

unRAID Mover and qBittorrent

When you make use of the unRAID cache drive for your /data/torrents share, and the torrents in qBittorrent are still seeding, the mover can't move files since they are still in use.

Using the following instructions will allow you to move the files with the use of the qBittorrent API.

Workflow Rules

  1. Pause torrents in a specified age range that reside on your cache drive.
  2. Run the unRAID mover.
  3. Resume the torrents after the mover has completed.

Warning

The screenshots below are only EXAMPLES to show you how it should look and where you need to place the data that you need to add. They are NOT always a 100% reflection of the actual data, and not always the actual values you need to add.

  • Always follow the recommendations described in the guide.
  • If you have any questions, or aren't sure, just click the chat badge to join the Discord Channel where you can ask your questions directly.

Needed

qBit-Mover script

Download the following standalone Python script.

Big Thnx to bobokun Developer of qBit Manage

Plugins

Install the following Plugins.

  • User Scripts
  • NerdTools
    • python3 (1)
    • python-setuptools (1)
    • python-pip (1)

(1) These need to be installed from NerdTools.


Setup

After you install the needed Plugins - it's time to configure everything.

qbittorrent-api module

The script needs the qbittorrent-api module to work, so we need to make sure it's installed when your unRAID server starts, or when the Array is started the first time.

You can choose one of the following 3 options (select a tab) to install qbittorrent-api.

With this option, we're going to install the qbittorrent-api module when the Array is started the first time.

In your unRAID Dashboard, go to your Settings tab and select User Scripts in the User Utilities section at the bottom.

!User Scripts

At the bottom of the User Scripts page select the ADD NEW SCRIPT button.

!Add New Script

A popup will appear asking you to name the script. For this example, we're going to use Install qBittorent-API and then click on OK.

!Install qBittorrent API

Click on the cogwheel of the new script in the list, and select Edit Script.

!Select user script

Copy/Paste the following in the new window that opens, then click SAVE CHANGES.

#!/bin/bash
pip3 install qbittorrent-api

!Bash script

Select in the schedule list when the script should run, and choose At First Array Start Only.

!Set Run Time

Click on Apply.

Finally, you will need to choose RUN IN BACKGROUND or restart your unRAID server to install the qbittorrent-api module.

!RUN IN BACKGROUND

With this option, we're going to create a Python virtual environment on our disk. We will use this to run and store dependencies (qbittorrent-api) for this specific environment.

By doing this, we will only need to configure this once and it will be persistent after reboots (this differs from the previous steps).

First, you need to choose a location to start a new Python environment.

Info

In the next steps, you will be asked to choose a location to store the script, try to be consistent.

Suggestions:

  • /mnt/user/appdata/qbittorrent/scripts/.venv
  • /mnt/user/data/scripts/.venv

Run the following command in unRAID's terminal in the directory you chose:

python3 -m venv --clear /mnt/user/data/scripts/.venv

We now need to enter this new environment and install our dependency (qbittorrent-api) in it, run:

source /mnt/user/data/scripts/.venv/bin/activate
pip3 install qbittorrent-api
deactivate # to leave the environment

Info

Replace /mnt/user/data/scripts/.venv with the path you have chosen.

With this option, we're going to install the qbittorrent module when the unRAID server is started.

On your USB stick/key go to /boot/config and open the go file with your text editor (VSCode/Notepad++).

Copy/paste the following command

pip3 install qbittorrent-api

Restart your unRAID Server or run the above command from the terminal.


Script

Now, using your favorite text editor (VSCode/Notepad++) edit the script you downloaded at the beginning of the guide (HERE).

You only need to change a few options at the top of the script.

# --DEFINE VARIABLES--#
# Set Number of Days to stop torrents between two offsets
# days_from set to 0 will pause any torrents from todays date
# days_to will be the upper limit of how far you want to pause torrents to
days_from = 0
days_to = 2
qbt_host = "192.168.2.200:8080"
qbt_user = None
qbt_pass = None
# --DEFINE VARIABLES--#
  • days_from => Set Number of Days to stop torrents from for the move.
  • days_to => Set Number of Days to stop torrents to for the move.
  • qbt_host => The URL you use to access qBittorrent locally. (the " should remain)
  • qbt_user => Your used qBittorrent User Name if you have authentication enabled. Add ' either side.
  • qbt_pass => Your used qBittorrent Password if you have authentication enabled. Add ' either side.

If you have authentication enabled. Add ' either side of your User/Password.

Depending on whether you use the unRaid Mover Tuning app, You might need to change line 68:

  • If you do not use Mover Tuning, change line 68 from os.system('/usr/local/sbin/mover.old start') to os.system('/usr/local/sbin/mover start')
  • If you use Mover Tuning but don't want to use it for the script, do not change line 68
  • If you use Mover Tuning and do want to use it for the script, change line 68 from os.system('/usr/local/sbin/mover.old start') to os.system('/usr/local/sbin/mover start'). For this option, inside the Mover Tuner options you will also need to set Move Now button follows plugin filters to Yes and Disable Mover running on a schedule to No.

Copy the script to your preferred location

Place the script you just edited somewhere easy to access/remember.

Suggestions:

  • /mnt/user/appdata/qbittorrent/scripts/mover.py
  • /mnt/user/data/scripts/mover.py

Final steps

Set up the scheduler for when the mover should run.

In your unRAID Dashboard, go to your Settings tab and select User Scripts in the User Utilities section at the bottom.

!User Scripts

At the bottom of the User Scripts page select the ADD NEW SCRIPT button.

!Add New Script

A popup will appear asking you to name the script. For this example, we're going to use qBittorrent Mover and then click on OK.

!qBittorrent Mover

Click on the cogwheel of the new script in the list.

!Select user script

Choose your method (select a tab) and copy/paste the script in the new window that opens, then click SAVE CHANGES.

    #!/bin/bash
    /usr/local/emhttp/plugins/dynamix/scripts/notify -s "qBittorrent Mover" -d "qBittorrent Mover starting @ `date +%H:%M:%S`."
    echo "executing script to pause torrents and run mover."
    python3 /mnt/user/data/scripts/mover.py
    echo "qbittorrent-mover completed and resumed all paused torrents."
    /usr/local/emhttp/plugins/dynamix/scripts/notify -s "qBittorrent Mover" -d "qBittorrent Mover completed @ `date +%H:%M:%S`."
    #!/bin/bash
    /usr/local/emhttp/plugins/dynamix/scripts/notify -s "qBittorrent Mover" -d "qBittorrent Mover starting @ `date +%H:%M:%S`."
    echo "executing script to pause torrents and run mover."
    /mnt/user/data/scripts/.venv/bin/python3 /mnt/user/data/scripts/mover.py
    echo "qbittorrent-mover completed and resumed all paused torrents."
    /usr/local/emhttp/plugins/dynamix/scripts/notify -s "qBittorrent Mover" -d "qBittorrent Mover completed @ `date +%H:%M:%S`."

Info

Replace /mnt/user/data/scripts/ in the script with the path you have chosen for the Python script.

!Bash script

Click the schedule dropdown to choose when the script should run. We want to select Custom.

!Set Run Time

After changing to Custom you will get an extra text field on the right where you can set your schedule (cron).

For this example, we're going to tell the script to run every day at 4 AM.

0 4 * * *

You can generate your scheduling HERE

!Set Run Time


Questions or Suggestions?

If you have questions or suggestions click the chat badge to join the Discord Support Channel where you can ask your questions directly and get live support.

Discord chat