Hey guys! Has anyone had success migrating a Plex server from Windows to Linux in recent years? I’m mostly concerned about losing watch history / users (having to reinvite).

I found this Reddit thread on the issue and it seemed like a simple copy and paste of the DB file. I attempted following both the official directions from their guide and from the Reddit post and ran into a SQLite DB error similar to what another user experienced in the Reddit thread:

soci::soci_error() that sqlite3 prepare failed…Error: Unable to set up server: sqlite3_statement_backend::prepare: file is not a database for SQL: PRAGMA cache_size=512 (N4soci10soci_errorE)

Has anyone done a migration in the recent years? Seems like something might have changed within the last few and this copy and paste of the DB file will not work anymore?

  • krnl386@lemmy.ca
    link
    fedilink
    English
    arrow-up
    1
    ·
    16 hours ago

    The error sounds like your sqlite database file is borked, misplaced or not named correctly. Make sure to shut down Plex on the source Windows machine fully before copying it over. Also make sure the path to the database file is valid - not sure where Plex stores that. Also keep in mind that Linux paths and file names are cAsE SenSiTiVE, so if your db file was named “Plex.db” on Windows, and the Linux version of Plex expects “plex.db” - you will get an error.

    Other issues to anticipate related to file/directory naming: library/metadata paths. You may need to redefine/rescan all your media libraries to fix that depending on how Plex handles transitions between platforms that use different path separators (Windows = \ and Linux/macOS = /) and case sensitivity (Windows and macOS = case INsensitive and Linux = case sensitive).

    Also consider a DB backup/restore (feature built into Plex) may be a better way to transition vs. just copying the DB file over.

    If you’re feeling adventurous, you can download a SQLite browser and take a peek at the Plex DB file. See if there are any red flags like paths to libraries that include Windows specific stuff like drive letters. That will probably break in Linux if just copied over. The backup/restore feature may account for that and actually try to take care of the differences… but that’s just a guess; I never tried this and have no experience with it.

    Note: I never bothered to run Plex on anything other than Linux.

    P.S. some here suggested using Docker (or Podman - probably better in the long run) to deploy Plex. I strongly recommend that option as well, since it abstracts a lot of the nuts and bolts that you no longer need to care about.

  • TedZanzibar@feddit.uk
    link
    fedilink
    English
    arrow-up
    12
    ·
    2 days ago

    Just to add to the info so far: while you’re spending the effort doing a migration it’s worth going the extra few steps and moving to their Docker image. It’ll make any future server moves a doddle, not to mention updates etc.

  • justlemmyin@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    1
    ·
    edit-2
    2 days ago

    On the phone right now, but i did this last month OP.

    First of all make sure to keep a backup of the db. Normally Plex does this for you every few days in the db folder. (From your old windows install)

    The missing ingredient most likely is converting all the windows registry entries into preferences.xml

    There was a reddit post where some one had posted a sample XML. I repopulated it with all the settings from the windows registry export. If you can’t find the post then I can post mine here in the morning.

    Also had to create a plex user and group and chown it to all the media. I am a new Linux user so had to fuck around a lot coz of Fedoras SELinux file perms.

    • justlemmyin@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      21 hours ago

      <an eternity later…> Yo yo OP! Here is my sample Preferences.xml, I have nulled out the fields you will need to fill up from the windows registry. After this I still had to reshare the libraries with my friends, unsure which step I botched, but that was easy to re-do.

      <?xml version="1.0" encoding="utf-8"?>
      <Preferences
      OldestPreviousVersion="1.18.3.2156-349e9837e"
      MachineIdentifier="####################"
      ProcessedMachineIdentifier="####################"
      AnonymousMachineIdentifier="####################"
      MetricsEpoch="1"
      AcceptedEULA="1"
      PublishServerOnPlexOnlineKey="1"
      PlexOnlineToken="####################"
      PlexOnlineUsername="####################"
      PlexOnlineMail="####################"
      LastAutomaticMappedPort="0"
      CertificateVersion="3"
      PubSubServer="####################"
      PubSubServerRegion="fmt"
      PubSubServerPing="485"
      LanguageInCloud="1"
      FriendlyName="####################"
      TranscodeCountLimit="3"
      TranscoderQuality="0"
      TranscoderH264BackgroundPreset="medium"
      ButlerUpdateChannel="0"
      DlnaEnabled="0"
      CinemaTrailersFromTheater="1"
      CinemaTrailersType="0"
      WanPerUserStreamCount="2"
      LanNetworksBandwidth=""
      allowedNetworks="192.168.1.0/24"
      customConnections=""
      ManualPortMappingMode="1"
      ManualPortMappingPort="####################"
      FSEventLibraryPartialScanEnabled="0"
      FSEventLibraryUpdatesEnabled="0"
      GenerateBIFBehavior="never"
      OnDeckWindow="52"
      ScannerLowPriority="0"
      ScheduledLibraryUpdateInterval="86400"
      ScheduledLibraryUpdatesEnabled="1"
      watchMusicSections="1"
      CloudSyncNeedsUpdate="0"
      ButlerTaskRefreshLibraries="1"
      MinutesAllowedPaused="30"
      DlnaReportTimeline="0"
      ButlerEndHour="7"
      ButlerStartHour="3"
      PlexOnlineHome="0"
      DvrIncrementalEpgLoader="0"
      EnableIPv6="0"
      WebHooksEnabled="0"
      CinemaTrailersPrerollID=""
      TranscoderCanOnlyRemuxVideo="0"
      PushNotificationsEnabled="0"
      LogVerbose="0"
      MergedRecentlyAdded="0"
      ButlerTaskCleanOldBundles="1"
      ButlerTaskCleanOldCacheFiles="1"
      ButlerTaskDeepMediaAnalysis="1"
      ButlerTaskGenerateAutoTags="0"
      ButlerTaskOptimizeDatabase="1"
      ButlerTaskRefreshLocalMedia="1"
      ButlerTaskRefreshPeriodicMetadata="1"
      ButlerTaskReverseGeocode="0"
      ButlerTaskUpgradeMediaAnalysis="1"
      GenerateChapterThumbBehavior="never"
      GenerateIntroMarkerBehavior="never"
      LoudnessAnalysisBehavior="never"
      MusicAnalysisBehavior="never"
      WanTotalMaxUploadRate="20000"
      autoEmptyTrash="1"
      GlobalMusicVideoPathMigrated="1"
      CertificateUUID="####################"
      secureConnections="1"
      DatabaseCacheSize="4000"
      ButlerTaskBackupDatabase="1"
      customCertificatePath=""
      PreferredNetworkInterface="eno1"
      CinemaTrailersFromBluRay="1"
      ButlerDatabaseBackupPath="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases"
      sendCrashReports="1"
      HardwareDevicePath="####################"/>
      
  • gazby@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 days ago

    Are you sure the db is identical on the new server (rsync -a or similar)? The error suggests the database is not even being recognized as such.

    • Sl00k@programming.devOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 days ago

      Everything was freshly installed and updated including the OS (PopOS as I’m running it on my gaming PC)

      • ragebutt@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        7
        ·
        2 days ago

        Is the windows side up to date? Most likely culprit would be a db mismatch if one side or the other is on a different version. Similarly, do you by chance have either side running a beta release? If you have plex pass you potentially have access to these

        Shameless moment to plug the idea that you could consider migrating to Jellyfin if you can’t solve the issue

      • CaptainBasculin@lemmy.ml
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 days ago

        Check the database version on both sides to make sure they match.

        Pop OS currently is keeping the next version update on alpha as they’re developing their own compositor display stack called COSMIC to go along with it; so some database dependencies might have outdated versions.