Created
September 6, 2021 01:43
-
-
Save stephanGarland/9a7370540a11191660dd05041ee1df80 to your computer and use it in GitHub Desktop.
Fix Plex database - the DB frequently gets borked for one reason or another; this backs up your existing one and copies over the latest backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Replace the directory on L7 with your actual location | |
echo "Stopping Plex" | |
docker stop plex | |
cd "/mnt/nvme_plex/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases" | |
existing="com.plexapp.plugins.library.db" | |
echo "Backing up $existing to $existing.bak" | |
cp $existing $existing.bak | |
backup=$(find . -regex ".*library\.db-[0-9]+.*" -print0 | xargs -r -0 ls -1 -t | head -1) | |
echo "Copying $backup to $existing" | |
cp $backup com.plexapp.plugins.library.db | |
echo "Deleting metadata" | |
rm com.plexapp.plugins.library.db-shm | |
rm com.plexapp.plugins.library.db-wal | |
echo "Restarting Plex" | |
docker start plex | |
echo "All done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment