How to Migrate a Plex Server to a New Server (Ubuntu/Linux)

This guide outlines the steps to migrate a Plex Media Server from one Ubuntu server to another while preserving your library data, watch history, and metadata.

Prerequisites

  1. Access: Root or sudo access to both the Source (Old) and Destination (New) servers.
  2. Media: Your actual media files (Movies, TV) must be at the exact same mount path on the new server as they were on the old one. If they change location, you will need to remap them later.
  3. Versions: Ensure both servers are running the same version of Plex Media Server to avoid database compatibility issues.

Step 1: Preparation on Source Server

  1. Disable “Empty Trash”:

    • Open Plex Web.
    • Go to Settings > Library.
    • Disable “Empty trash automatically after every scan”.
    • Reason: This prevents Plex from deleting your metadata if it temporarily can’t find your media files during the move.
  2. Stop Plex Service:

    sudo systemctl stop plexmediaserver
    

Step 2: Backup Data (Source)

The critical data is located in /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/.

  1. Archive the Data: We will create a compressed archive of the Application Support directory. This preserves permissions and symlinks.

    cd /var/lib/plexmediaserver/Library/Application Support/
    sudo tar -czf ~/plex_backup.tar.gz "Plex Media Server"
    

    Note: This file can be very large depending on your library size (especially if video previews are enabled).

  2. Backup Preferences: The Preferences.xml file contains your server identity. It is included in the folder above, but verifying its existence is good practice.

    Location: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml


Step 3: Preparation on Destination Server

  1. Install Plex Media Server: Download and install the .deb package from the official Plex website, or use the repository.

    # Example (Check plex.tv/downloads for the latest URL)
    wget https://downloads.plex.tv/plex-media-server-new/1.x.x.x/debian/plexmediaserver_1.x.x.x_amd64.deb
    sudo dpkg -i plexmediaserver_*.deb
    
  2. Stop Plex Service: The installation automatically starts the service. We must stop it to overwrite the data.

    sudo systemctl stop plexmediaserver
    
  3. Backup Original Data (Optional): Move the fresh (empty) installation data aside just in case.

    cd /var/lib/plexmediaserver/Library/Application Support/
    sudo mv "Plex Media Server" "Plex Media Server.original"
    

Step 4: Transfer and Restore

  1. Transfer the Archive: From the Source server, use scp (or rsync) to copy the backup to the Destination server.

    # Run this on the SOURCE server
    scp ~/plex_backup.tar.gz user@new-server-ip:~/
    
  2. Extract on Destination: On the Destination server, extract the archive to the correct location.

    # Run this on the DESTINATION server
    sudo tar -xzf ~/plex_backup.tar.gz -C /var/lib/plexmediaserver/Library/Application Support/
    

Step 5: Fix Permissions

Using tar usually preserves permissions, but it is critical to ensure the plex user owns the files.

sudo chown -R plex:plex /var/lib/plexmediaserver

Step 6: Start and Verify

  1. Start Plex:

    sudo systemctl start plexmediaserver
    
  2. Verify Access:

    • Open a web browser and go to http://<new-server-ip>:32400/web.
    • You may need to sign out and sign back in to reclaim the server.
    • Check that your libraries appear and your “On Deck” / “Continue Watching” status is intact.
  3. Cleanup:

    • Re-enable “Empty trash automatically after every scan” in Settings > Library.
    • (Optional) Delete the plex_backup.tar.gz file once you are confident everything is working.