Ubuntu needs to be reinstalled, and I'm terrified

Following a recent update in 18.04, Ubuntu seems to be fried and I’m going to have to reinstall, I think. I’ve put a ton of work into my Plex database, and I’m really not keen on redoing everything, but past attempts to back up and move the database to my current computer were a disaster.

Is there a step-by-step on how to back up the Plex database in Ubuntu from a live USB, and restore it with a fresh Ubuntu install?

I know not Linux BUT I must say the most important thing here is the database. That will have ALL your edits/manual changes. Just get a hold of the db file. Everything else(if not backed up/restored) is just a sit and wait till everything gets re-scanned and metadata downloaded.

Just remember, the information in your plex database isn’t/doesn’t use relative paths for media and metadata. Be SURE you put all media(use same paths as before) if you reinstall the OS and add everything back.

Oh yeah, one important note. Always COPY the backup db to the new install. That way if it all goes south you still have a copy of the original db.

Good luck!

1 Like

And just to add if you arent 100% sure of your previous paths make sure the VERY first thing you do after the reinstall of Plex is to disable the default setting of Empty trash after media scan.

All your files may show as missing however it will allow you to see the paths that Plex expected to find the files.

1 Like

That’s an excellent point!

1 Like

Thanks to both; I’ve spent about four hours trying to recover from an initramfs/kernal panic issue, which has me exploring new territory including chrooting and even updating my BIOS. I’m almost at the reinstall point and anxious about it.

1 Like

Sadly like @NewPlaza I’m a Windows kiddie (closing in on a pension in truth). So can’t help much more sadly.
I have run seedboxes and dedicated servers with Linux but mostly using a script.
I know for a fact than depending on the distro and if Plex is or isn’t running in docker then the location of the Plex data folder can vary wildly… even if u manage to gain access to the previous system.

Yeah. Just remember though. You will never loose plex if you keep the database(and your media of course, lol). It’s the heart and soul(it’s everything). No matter how many mistakes you may make in restoring your PMS you can always come back to your db file. Metadata is a far second. As long as you install PMS in the same location you did before and your shares are all in the same place(same path as before) then Plex will see nothing different as before.

Great. I’m backing up my 2GB database to an external hard drive now, and will be taking photos of the ls -l file paths of all the data just to make sure I can rebuild. The media is all regularly backed up externally anyway.

I’ve been away for the day. May I summarize the steps?

  1. Before shutdown:
    a. Disable Empty Trash after each scan
    b. Disable Automatically Update
    c. Save the changes
  2. Shutdown PMS
  3. Clone the existing PMS from a terminal window
sudo sh
cd /var/lib/plexmediaserver
tar cfz /path/to/save/location/PlexLibrary.tar.gz .
  1. With the Library now cloned, Now copy your /etc/fstab entries for later informational use when setting up the mounts again.
  2. Do your reinstallation of Ubuntu / install any needed packages
  3. Get your media mounted and ready in /etc/fstab
  4. Install PMS
  5. Let it run once then stop it
  6. Reload the cloned copy In a terminal window
sudo sh
cd /var/lib/plexmediaserver
rm -rf *

# extract the cloned copy back into position
tar xf /path/to/previously/made/clone/PlexLibrary.tar.gz

# set UID/GID to match those of user plex in this Ubuntu installation
chown -R plex:plex .
  1. Start PMS
  2. Now go through each library section and edit each folder to reflect the new path (if changed) and all unvailable media is again available.
  3. Re-enable automatic scanning and detection.
  4. Re-enable Empty Trash
  5. Empty the Trash
  6. Clean the bundles
  7. Optimize Database # these 3 steps clean up the db after all the edits it just had
3 Likes

Brilliant, Chuck, thanks so much. I’ll start working away at it tonight.

1 Like

Gives me

tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more information.

Ubuntu is so dead that I’m only in my system via chmod, and I can’t figure out how to create a cp command that moves the tar to a mounted USB drive, so I’m trying to just create the tar in place and then move it in Nautilus.

Edit: figured it out;

tar -cvfz PlexLibrary.tar.gz Library

Forgot to type that last part? :slight_smile:

“Cowardly refusing” means the argument count is wrong or the command options are wrong.

It would have helped to see what you wrote.

FYI, given the number of files involved, v (verbose) is often skipped due to the volume of output generated and it slowing down the process.

The - was missing before -cfz, so it wasn’t recognizing the command. Verbose was actually kind of fun!

interesting…

[chuck@lizum plexmediaserver.125]$ 
[chuck@lizum plexmediaserver.125]$ ll
total 8
drwxr-xr-x.  4 xplex plex   65 Jun  3 20:30 ./
drwxr-xr-x. 73 root  root 4096 Mar 12 18:17 ../
-rw-------.  1 xplex plex 1211 Sep  5  2018 .bash_history
drwxr-xr-x   5 xplex plex   69 Jan 28 09:05 Library/
drwxr-xr-x   3 xplex plex   98 Mar 17 19:58 tmp_transcoding/
[chuck@lizum plexmediaserver.126]$ sudo tar cfz lib.tar.gz ./Library
[chuck@lizum plexmediaserver.127]$ 

At any rate, the reinstall is now giving me an arch-independent elf magic error so this may not see any progress until I can find some time to crack away at that.

The error was mine, Chuck – I left out the trailing .in your code above, and accidentally resolved it when I added Library to indicate the Library folder. The minus wasn’t needed at all. I’d edit my reply above but you’ve already followed up on it and it would make this thread kind of incoherent.

Everything worked perfectly! Thanks so much, Chuck.

Excellent! :+1:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.