Migrating Plex Metadata from Unraid to Ubuntu

This post is currently a work in progress.

I will be including some additional screenshots and media as I prepare them, and will remove this message once the post is complete.

Summary

So you’ve read JDM’s QuickSync guide and you’ve decided to switch from your previous “One Server To Rule Them All” approach to a separate NAS and dedicated QuickSync system. You get to the point in the guide where it tells you to create new libraries, and you ask yourself, “Can’t I just copy my libraries from the old server?” Good news! Yes, you can copy your libraries and metadata from one server to another, and it’s only a few extra steps versus creating them from scratch. Here’s how you do it:

I borrowed most of these steps from JDM’s guide, because 95% of what you’re doing is going to be identical. I just updated the formatting slightly, threw in a few screenshots and added my steps where necessary.

Instructions

1. Configure Unraid
  • Enable NFS under Settings > NFS

  • Export your media shares. Go to Shares and select the share you want to export to linux.

  • Under NFS Security Settings change Export to Yes and Security to Private.

    • Repeat this step for every media folder you want to share with linux.
  • Go to the Docker tab and edit your Plex container settings. Make a note of the host and container paths for your media folder(s) and appdata folder. You will need them later. Here’s a screenshot of my paths for reference:

  • Close the container settings without changing anything, then stop the Plex container. You can’t have it running when you transfer the data to the new system.

2. Install and Configure Ubuntu

I differ from JDM here, I prefer to use Ubuntu server, where he recommends Ubuntu desktop. My reasoning is once Plex is installed you shouldn’t really need to interact with the system locally outside of an occaisonal update, so why waste resources running a GUI that’s not going to be used? But I will leave that decision up to you and provide links to both images.

Ubuntu Server: http://releases.ubuntu.com/disco/ubuntu-19.04-live-server-amd64.iso
Ubuntu Desktop: http://releases.ubuntu.com/disco/ubuntu-19.04-desktop-amd64.iso

  • Make a bootable install disk using Rufus on a Windows machine, using an empty flash drive 8GB or larger.

  • Boot to the USB drive on your new server and go through the installation process.

    • You can stick with the defaults on nearly all of the steps. You will want to enable the OpenSSH server when you get to that step, but you won’t need any of the other optional software.

    • Here’s a video walkthrough of the installation process for Ubuntu Server 19.04:
      [VIDEO COMING SOON]

  • Log into your new Ubuntu installation and install the latest updates by entering
    sudo apt update && sudo apt upgrade -y

    • Please note, all commands and folders in linux are case sensitive, so make sure you enter the commands exactly as written

    • It will prompt you for a [sudo] password, this is the same password you entered for your account when you created it. You’ll need to enter your password the first time you run a sudo command. Subsequent commands won’t always prompt you for a password, there’s a timeout period (15 minutes by default) after which it will prompt you again.

    • You can either do these steps directly on the machine, or you can use a terminal emulator program such as Putty. I would recommend grabbing Putty even if you don’t use it now, since it will come in handy for future maintenance on the system.

  • Once the updates have finished, install the NFS utilities by entering
    sudo apt install -y nfs-common

3. Prepare and Mount Network Share Locations
  • Enter the following: sudo nano /etc/fstab. This command opens the filesystem table (/etc/fstab) in an easy to use text editor (nano), using the root user account (sudo). Your screen should look something like this:

  • Press the down arrow to move the cursor below all of the default entries, there should only be one or two.

  • Grab that list of container paths you saved from step 1. For each media path in that list, enter a line like the following:
    <server ip>:<host path>/<container path> nfs defaults 0 0

    • For example, using the paths from my screenshot in step 1, here’s how I would enter them:
      10.0.0.172:/mnt/user/movies /movies nfs defaults 0 0
    • The forward slashes / are important, make sure you enter them exactly as you see them in your container settings
  • Once you’ve entered your paths, your screen should look something like this:

  • Next, press Ctrl+O (Letter o) and you will see a prompt File Name to Write: /etc/fstab. Just hit Enter here to accept the default. Then, press Ctrl+X to close the text editor.

  • Now that the paths are added to the filesystem table, you need to create local folders for each media folder you added.

    • Enter the following sudo mkdir -p /<container path> once for each media folder you have. For example, I entered sudo mkdir -p /movies for my movies folder.
  • Once that’s finished, test mounting one of the folders.

    • Enter the following sudo mount /<container path> for just one of the folders. For example, I entered sudo mount /movies
    • If you didn’t get an error message, type ls /<container path> and verify that your media shows on the screen, like this:
4. Install Plex
  • Download and install Plex for Linux here.

    • If you were using the Plex Pass install in unraid, make sure you enable that option before you download.
    • Choose the Ubuntu (16.04+) / Debian (8+) - Intel/AMD 64-bit download.
  • Copy the downloaded file to your Unraid server temporarily, in the same media folder that you used to test the NFS mounting from the previous step.

  • Install Plex using the following command:
    sudo dpkg -i /<container path>/plexmediaserver_<version>_amd64.deb.

    • Here’s a quick tip. You can use the Tab key to autocomplete in the linux terminal. So, for the command above, you could type sudo dpkg -i /movies/plex and then hit Tab and it should fill in the rest of the filename automatically. If it beeps at you instead, type a few more characters and press Tab again.
  • Once Plex has been installed, stop the Plex server temporarily by entering
    sudo systemctl stop plexmediaserver

5. Migrate your Metadata
  • Remove the existing Plex metadata folder, enter
    sudo rm -rf /var/lib/plexmediaserver/Library (Note the capital L in Library)

  • Copy the metadata folder from your unraid install using rsync, using the following command:

    • sudo rsync -azvh root@<unraid IP>:/<plex appdata location>/ /var/lib/plexmediaserver/

      • The trailing slashes are important on both paths, for example: /mnt/user/appdata/plex/

      • This process may take some time, you’ll see a ton of files scrolling by as it syncs them from unraid to ubuntu. Once rsync has completed, it will show you the totals of what was transferred and transfer speed. If there were any errors in transferring the data, it will show those as well.

    • Assuming there were no errors, there’s just one more step. The files on unraid are owned by the user nobody, but Plex on Ubuntu is expecting the files to be owned by the plex user. Enter the following command to change ownership of the metadata files in Ubuntu:
      sudo chown -R plex:plex /var/lib/plexmediaserver/

    • Verify the ownership was changed properly by entering
      ls -l /var/lib/plexmediaserver/
      and make sure the output looks something like this:

6. Reboot and Test

At this point, all of the hard work is done. Now you just need to reboot the Plex system to ensure the NFS shares mount and Plex starts automatically after the restart. Enter sudo reboot in the terminal and your system will automatically restart. Once it has rebooted, open a browser and go to the Plex web interface,http://<ubuntu_ip>:32400/web. Plex may bug you to sign in, and once you’re signed in, you should see your Plex home screen with all of your media intact. Test a file from one of your libraries, it should start playing with no issues.

7. Post-Install Updates

Now that Plex is working properly on your new server, you’ll want to update your other programs to point at the new server. Check your config for Tautulli, Sonarr, Radarr, etc., and make sure your router’s port forward is pointing to the new server as well. You can also remove your Plex container and metadata from unraid to free up the space.

6 Likes

For anyone else looking for this answer that @Mthrboard has provided in the discord:

The question was how do you give your quick sync plex box WRITE permissions, You have to do this for each IP & NFS share you wish to grant write access to.

Notably, Plex Camera Sync will not work without write permission.

Mthrboard [US]Today at 1:09 AM

Unraid exports NFS shares as read only by default.

Your fstab is most likely fine. In unraid, under the share you want to export, set the NFS security to Private and apply.

A new box will pop up called Rules. In this box, type the IP of the machine you want to have write access followed by (rw) like so 192.168.1.10(rw) .

If other systems need write access you can enter more than one IP set separated by spaces 192.168.1.10(rw) 192.168.1.20(rw) and so on. If you want other systems to access the share read only append *(ro) after the last IP

If you have a LAPTOP, make sure you disable the lid-close event. Otherwise every time you close the laptop lid it goes to sleep. I learnt this the hard way. Here’s how to disable it.

sudo sh -c 'echo "HandleLidSwitch=ignore" >> /etc/systemd/logind.conf' && sudo reboot