Moving Plex metadata and content to external drive

This is a WIP post to help guide me to move Plex metadata and content from your computer’s internal drive to an external drive.

The reason for moving the content: with Plex your internal drive space will reach a limit. Thus you would like to have your content on an external drive with a much larger capacity.

The reason for moving the metadata: from time to time you may want to upgrade your machine that is the host for your Plex server and not lose all the metadata which will contain the images, thumbnails, ratings and watch status. So my solution is also to move the metadata to an external drive.

By doing this, I have a single place to keep all my Plex content and metadata – which will help with backups and future migrations.

My preferred approach to doing this is to minimise dealing with any coding and configuration of the Plex settings. So I will aim to use the Plex interfaces and file management system as much as possible to achieve this.

The first step: update and do final synchronise of the existing Plex server and content

Second step: stop the Plex server

Third step: copy (not move) the content to the new external drive

Fourth step: start the Plex server

Fifth step: update the content library locations in the Plex server interface. Use edit libraries to add the new external drive location for your content without removing or deleting the old library locations. Do this library by library at a time, to mitigate risks. Then remove the old library and re-scan the library.

Sixth step: once all content locations have been updated to the new external drive location, then clean up the database and trash. Stop the Plex server.

Seventh step: move the metadata to the external drive. Check the locations of where the Plex Metadata Server is stored – which differs by OS. This may take a long time since there will be a huge number of small files. Best to compress the directory location and move to the next location and extract from there to ensure completeness of the transfer.

Eighth step: create symlink on the computer to point to the Plex Metadata Server location on the location on the external drive. This will be different on different OS.

Ninth step: for linux systems, check permissions and ownerships of the plex metadata and content directories using chmod and chown.

Tenth step: start the Plex server

Some of the resources I use as reference for this research:

[Plex] Where is the Plex Media Server data directory located?

[Plex] Move an Install to Another System

[Reddit] Moving Plex config and metadata to external drive

[Plex] Move Media Content to a New Location

In copying files from one disk to another disk, I come across three methods: cp, dd and rsync. I am not absolutely sure about when is best to use which one. However, dd is best used to clone disks and operates at the block level, low level.

If you are making a backup, rsync is sufficient. It operates at the file system level, above block device level.

“This approach is considered to be better than disk cloning with dd since it allows for a different size, partition table and filesystem to be used, and better than copying with cp -a as well, because it allows greater control over file permissions, attributes, Access Control Lists (ACLs) and extended attributes.”

So for this purpose, I would use rsync to do the copy as it seems to be quite powerful. Some guides on rsync:

rsync -avxHAX --progress / /new-disk/

rsync options are:

-a  : all files, with permissions, etc.. equals -rlptgoD (no -H,-A,-X)
-r, --recursive	: recurse into directories
-v  : verbose, mention files
-x  : stay on one file system
-H  : preserve hard links (not included with -a)
-A  : preserve ACLs/permissions (not included with -a)
-X  : preserve extended attributes (not included with -a)
-a, --archive : archive mode; equals -rlptgoD (no -H,-A,-X)
-t, --times   : preserve modification times
-q, --quiet   : Suppresses non-error messages.
--no-motd     : Suppresses daemon-mode message of the day

Use --info=progress2 instead of -P or --progress which is useful for large transfers, as it gives overall progress, instead of (millions of lines for) individual files.

Add -S to “handle sparse files efficiently” in case there is a docker devicemapper volume or similar to be copied.

To improve the copy speed, add -W (--whole-file), to avoid calculating deltas/diffs of the files. This is the default when both the source and destination are specified as local paths, since the real benefit of rsync’s delta-transfer algorithm is reducing network usage.

Also consider adding --numeric-ids to avoid mapping uid/gid values by user/group name.

Perfect for copying large amounts of files, use rsync -axHAWXS --numeric-ids --info=progress2.