How to migrate the arr apps to the new truecharts CNPG

We show in this post the detailed steps to migrate the arr charts from sqlite to Cloud-Native Postgres (lidarr, radarr, readarr, prowlarr).

Overview

Unless otherwise noted, the steps presented next are the same for lidarr, radarr, readarr and prowlarr. Note that for now, the sonarr and whisparr charts still use sqlite, therefore the database migration is not necessary for them.

The steps are:

  1. Backup old charts
  2. Reinstall the app
  3. Migrate the database

Prerequisites

  • Know how to open a shell into truenas (either through the online shell or using ssh).
  • Heavyscript must be installed.
  • The tcdbinfo script must be downloaded/copied somewhere accessible on your NAS.
  • Install the pgadmin charts. You can keep the default settings (just enter a username/password).
  • Install the flaresolverr charts (it can also be any other chart that has access to the apt command).
  • Install pgloader:
    • Go inside the shell of flaresolverr (using, e.g., heavyscript or the shell button in the app config of the truenas web UI).
    • Type apt update
    • Type apt install wget
    • Type cd /config
    • Type wget https://github.com/Roxedus/Pgloader-bin/releases/download/999791d/pgloader
    • Type chmod +x pgloader

Backup old charts

  • Launch heavyscript and create a backup. This will backup the entire ix-applications pool.
  • For each *arr app, open their web UI and click on System -> Backup -> Backup Now. Click on the new backup to download it on your computer.
  • (All except sonarr/whisparr):
    • Unzip the backup of each app.
    • Send the *.db files to your NAS.
    • I used my SMB pool for that, but it can also be done using ssh (with the scp command).
    • Using heavyscript, mount the PVC of flaresolverr.
    • Move the *.db files to the mounted PVC.
    • Unmount the PVC and restart flaresolverr.

Reinstall the app

Note: I delete the old chart before installing the new one because I want to keep the same app name as before. I don’t think it is particularly unsafe to do so because we have the heavyscript backup and each *arr app’s separate backups, but if you want to create the new one before deleting the old one, that’ll work too.

  • Take note of the previous charts settings (ingress, hostpath, whatever else you changed from the default config).
  • Delete the previous chart.
  • Install the new chart using the same settings you had.
  • When it is deployed, check that you can correctly open the web UI.
  • (Sonarr/Whisparr only): click on System -> Backup -> Restore Backup and choose your backup file. The app should restart and everything should be back.

Migrate the database

  • Execute the tcdbinfo script. You should see the postgres connection info for your newly installed *arr apps.
  • Login to pgadmin.
  • On the left, right-click on Servers and click on Register -> Server.
  • In General, just type the name of the app.
  • In Connection, type the address, username and password given by the tcdbinfo script.
  • Click Save.
  • On the left, click on Servers -> app name -> Databases -> app name.
  • Right-click on the selected element and click on Query Tool.
  • The command you have to type here will depend on the app:
    • For prowlarr, you don’t need to type anything.
    • For lidarr, type
      • DELETE FROM “QualityProfiles”;
      • DELETE FROM “QualityDefinitions”;
      • DELETE FROM “DelayProfiles”;
      • DELETE FROM “Metadata”;
      • DELETE FROM “MetadataProfiles”;
    • For radarr, type
      • DELETE FROM “Profiles”;
      • DELETE FROM “QualityDefinitions”;
      • DELETE FROM “DelayProfiles”;
      • DELETE FROM “Metadata”;
    • For readarr, type
      • DELETE FROM “QualityProfiles”;
      • DELETE FROM “QualityDefinitions”;
      • DELETE FROM “DelayProfiles”;
      • DELETE FROM “MetadataProfiles”;
  • Click on the Execute/Refresh button. In the bottom pane, it should say that the operation was successful.
  • Open the flaresolverr shell.
  • Type cd /config.
  • Type ./pgloader --with "quote identifiers" --with "data only" --with "prefetch rows = 100" --with "batch size = 1MB" [app name].db 'postgresql://[username]:[password]@[address]/[app name]', substituting [app name], [username], [password] and [address] with the same info provided by tcdbinfo that you used in pgadmin.
  • Some warnings/errors are normal.
  • Optional: if you want to keep the same api key you had before:
    • Log into your app shell.
    • Type cd /config.
    • Type nano config.xml
    • Replace the api key with your old one (it is in the zip of the backup done at step 1).
  • Open your app’s web UI.
  • Click on the button on the top-right.
  • Click on restart.
  • Wait 2 min and reload the page.
  • If the migration was successful, everything should appear.
  • If the poster/cover images do not appear, just click on Update all and they should reappear.
Jaël Champagne Gareau
Jaël Champagne Gareau
PhD Student of Computer Science

My research interests include AI (both planning and machine learning) and theoretical computer science.