Plex Media Server (move or clone)
I followed a number of articles on this that I found, but Move an Install to Another System is the one I followed the closest. However, this article doesn't even come close to all the help needed.
We consider what it means to copy the contents of an existing Plex Media Server (source system) to another, new server (destination system).
# systemctl stop plexmediaserver
In the steps below, destination refers to the host where the new Plex Media Server is located. In my case, this is nargothrond whereas my original system, source, is tol-eressea. You must adjust the command line for your own circumstances.
# systemctl stop plexmediaserver
russ@tol-eressea:~$ locate "Library/Application Support/Plex Media Server" | head /var/lib/plexmediaserver/Library/Application Support/Plex Media Server /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Codecs /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Crash Reports /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Diagnostics /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Media /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Metadata /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins
Note that, because I installed and already launched Plex on my new, destination system, all (or most) of these files already exist:
root@nargothrond:/# ll /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server total 36 drwxr-xr-x 8 plex plex 4096 Aug 3 12:44 . drwxr-xr-x 3 plex plex 4096 Jul 11 10:00 .. drwxr-xr-x 4 plex plex 4096 Aug 3 11:45 Cache drwxr-xr-x 3 plex plex 4096 Jul 29 20:38 Codecs drwxr-xr-x 4 plex plex 4096 Jul 29 20:38 'Crash Reports' drwxr-xr-x 3 plex plex 4096 Aug 2 02:36 Logs drwxr-xr-x 3 plex plex 4096 Jul 11 10:01 Plug-ins drwxr-xr-x 7 plex plex 4096 Jul 11 10:00 'Plug-in Support' -rw------- 1 plex plex 703 Aug 3 12:39 Preferences.xml
Here are the commands for coping from the source system:
russ@tol-eressea: # cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server russ@tol-eressea: # scp -rp Codecs nargothrond:/var/lib/plexmediaserver/Application\ Support/Plex\ Media\ Server russ@tol-eressea: # scp -rp Diagnostics nargothrond:/var/lib/plexmediaserver/Application\ Support/Plex\ Media\ Server russ@tol-eressea: # scp -rp Logs nargothrond:/var/lib/plexmediaserver/Application\ Support/Plex\ Media\ Server russ@tol-eressea: # scp -rp Media nargothrond:/var/lib/plexmediaserver/Application\ Support/Plex\ Media\ Server russ@tol-eressea: # scp -rp Plug-ins nargothrond:/var/lib/plexmediaserver/Application\ Support/Plex\ Media\ Server russ@tol-eressea: # scp -rp Plug-in\ Support nargothrond:/var/lib/plexmediaserver/Application\\ Support/Plex\\ Media\\ Server" russ@tol-eressea: # scp -rp Preferences.xml nargothrond:/var/lib/plexmediaserver/Application\ Support/Plex\ Media\ Server
Note that Metadata and plex-database-backup for me are special. Because I want these backed up along with the media files (residing on a mirrored, zfs volume), I will
russ@tol-eressea: # cd /plex-movies russ@tol-eressea: # scp -rp Movies nargothrond:/plex-media russ@tol-eressea: # scp -rp Documentaries nargothrond:/plex-media russ@tol-eressea: # cd /plex-television russ@tol-eressea: # scp -rp TV nargothrond:/plex-media russ@tol-eressea: # scp -rp Metadata nargothrond:/plex-media russ@tol-eressea: # scp -rp plex-database-backup nargothrond:/plex-media
Note that I have Plex application subdirectories, Metadata and plex-database-backup, to copy. These I don't want on nargothrond's system disk because that disk isn't mirrored.
tol-eressea:# systemctl restart plexmediaserver
nargothrond:# cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server nargothrond:# ln -s /plex-media/Metadata nargothrond:# cd Plug-in\ Support nargothrond:# rm -rf Databases nargothrond:# ln -s /plex-media/plex-database-backup ./Databases
nargothrond:# reboot nargothrond:# systemctl restart plexmediaserver
Copying user-owned data between two Linux (Unix) hosts is problematic. The data is owned by user plex, group plex. But, user plex has no password, home directory or other accoutrements to facilitate copying between two machines. You must create a "real" user, superplex here, and make it belong to group plex and you must make use of root judiciously to get around trouble.
On both hosts (though mainly for the target), create the new user:
# useradd -d /home/superplex -m superplex # passwd superplex # usermod -a -G plex superplex
Edit /etc/passwd to change /bin/sh to /bin/bash.
The working formula, that gets around all the nasties, appears to be to use root on the source, modify the target directory to be writable by user superplex, then use this command to clean things up when finished. An example of target-host-subdirectory would be Plex Media Server. I had to modify it to allow superplex write access temporarily:
# chmod g+w /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server
Later, after the big copy, I fix that up as well as original ownership by user plex by doing this:
# chmod g-w /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server # chown plex:plex -R target-host-subdirectory
Here's a sample copy command, copying from the source server (tol-eressea in my case) to the target server (nargothrond in my case). Note the tricks using scp:
# scp -rp Codecs superplex@nargothrond:"/var/lib/plexmediaserver/Library/Application\\ Support/Plex\\ Media\\ Server/"
Hacking around at the server to figure out why...
This is the URL to use http://localhost:32400/web in answer to the above. This takes the browser directly to the web pages of the server itself. (I'm running my newest Plex Media server on a Linux Mint desktop instead of my usual headless, Ubuntu Server.)
Ultimately, the Preferences.xml file is problematic. There are sort of hidden settings here that are relevant including usernames and magic identities (ids). These have come over from the cloned Plex Media server and they won't work. The new server will be all about making you create new libraries and rescan content. This is why you cloned in the first place: in order not to have to do that again. It is necessary to remove this file, but first, you must shut down the Plex Media server:
# systemctl stop plexmediaserver # pushd "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server" # mv Preferences.xml Preferences.xml.old # popd # systemctl start plexmediaserver
Here is a Plex support article URL: