DietPi-Arr_to_RAM | Link Sonarr/Radarr/Lidarr database files to RAM

Everything you need to download and start your DietPi experience.
Locked
User avatar
MichaIng
Legend
Posts: 1146
Joined: Sat Nov 18, 2017 5:21 pm

DietPi-Arr_to_RAM | Link Sonarr/Radarr/Lidarr database files to RAM

Post by MichaIng » Sun Apr 14, 2019 6:46 pm

With v6.18 we silently added a new script that allows linking Sonarr/Radarr/Lidarr database files to RAM, increasing access performance, reducing disk I/O and avoiding constant external HDD spinning due to the very regular access to these files. This script has gone through some rework and polishing with v6.23 and can now be enabled to automatically link those databases to RAM on boot and store them back to disk on shutdown. Many thanks to @Dr0bac at this place for providing valuable input and testing the development progress constantly: https://github.com/MichaIng/DietPi/issues/2689

The database contains settings for the program and information about handled media. The media files themselves are not included of course, only the information about: which are to be searched for, which have already been downloaded/imported etc.

After Sonarr, Radarr or Lidarr has been installed and you rebooted or reloaded the current terminal session at least one time, simply run dietpi-arr_to_RAM to get usage information:

Code: Select all

Usage: dietpi-arr_to_RAM <command> [<program>]
Available commands:
  1 [<program>]         Link (program) database(s) to RAM
  2 [<program>]         Update (program) database backup(s)
  0 [<program>]         Store (program) database(s) back to disk
  enable                Enable Link to RAM on boot
  disable               Disable Link to RAM on boot
Supported programs:
  <empty>               Apply to all supported and installed programs
  sonarr                Apply to Sonarr database only
  radarr                Apply to Radarr database only
  lidarr                Apply to Lidarr database only
When running dietpi-arr_to_RAM 1 all found databases are linked to RAM. You find them in at: /tmp/{sonarr,radarr,lidarr}_db_link
A backup for each linked file is created automatically (and recovered if required), so in case of a system crash only changes from the time of the link are lost. When running the above manually, before shutting down, run dietpi-arr_to_RAM 0 to store the files back to disk.

To have all databases linked to RAM at boot and stored back to disk on shutdown automatically, run: dietpi-arr_to_RAM enable

To further reduce the risk of lost info/settings you can run dietpi-arr_to_RAM 2 to update the backups. This can also be done per-program, e.g. dietpi-arr_to_RAM 2 sonarr to only update the Sonarr database backup. This allows the program itself to do this as well. Within Sonarr, Radarr and Lidarr web UI you can configure custom scripts to be run on certain triggers, e.g. when a download has been finished.
For this:
  1. Open the web UI, e.g. for Sonarr <local_IP>:8989
  2. Go to Settings
  3. Select the tab Connect
  4. Select + to add a new notification
  5. Select Custom Script
  6. Give it some name and select the trigger sliders as desired, On Download makes most sense here since after download the disk is spinning already and the info is important enough to assure it is preserved even on system crash.
  7. As path choose: /DietPi/dietpi/misc/dietpi-arr_to_RAM
  8. As arguments enter e.g. 2 sonarr for Sonarr, 2 radarr for Radarr etc.
  9. Select Test to verify you entered everything correctly, then Save

Locked