plex-db-sync
plex-db-sync copied to clipboard
Issues with Permissions and DB Corruption
Hey @Fmstrat! First thanks for this awesome script.
I've got a few issues. I first tried using docker, but the script would fail, and I didn't know how to debug it. I started to follow your manual instructions instead
-
I have several times ended up with a corrupted database after running the script. Plex won't load and I have to delete and revert to a previous copy. it might have to do with wonky permissions.. I initially started with docker and then moved to bare metal for plex
-
Permissions are changed from plex:plex to my user. Should I be part of the plex group?
-
I am challenged with a password when the script executes
service plexmediaserver start. I assume I should be avoiding that somehow
Thanks in advance for your help!
The permissions on the db is changed? The db needs to always have plex:plex permissions. Why not run the script with the plex user?
@ddurdle if you run the script with the plex user, won't you still have issues starting and stopping services? Also, would you run your ssh commands with the plex user too?
@dpeet What are the permissions on the db file and containing folder?
@dpeet Could you test the plexuser branch? https://github.com/Fmstrat/plex-db-sync/tree/plexuser
I added a sudo to the owner of the DB specified in PlexDB1.
sure! Below is my local plex
-rwxrwxr-x 1 plex plex 69632 Feb 21 16:42 com.plexapp.dlna.db
-rwxrwxr-x 1 plex plex 32768 Feb 21 16:42 com.plexapp.dlna.db-shm
-rwxrwxr-x 1 plex plex 292552 Feb 21 16:42 com.plexapp.dlna.db-wal
-rwxrwxr-x 1 plex plex 715776 Jan 20 00:21 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 plex plex 715776 Feb 10 02:00 com.plexapp.plugins.library.blobs.db-2019-02-10
-rw-r--r-- 1 plex plex 715776 Feb 13 02:00 com.plexapp.plugins.library.blobs.db-2019-02-13
-rw-r--r-- 1 plex plex 715776 Feb 16 02:03 com.plexapp.plugins.library.blobs.db-2019-02-16
-rw-r--r-- 1 plex plex 715776 Feb 19 02:03 com.plexapp.plugins.library.blobs.db-2019-02-19
-rwxrwxr-x 1 plex plex 32768 Feb 21 16:42 com.plexapp.plugins.library.blobs.db-shm
-rwxrwxr-x 1 plex plex 0 Feb 21 16:42 com.plexapp.plugins.library.blobs.db-wal
-rwxrwxr-x 1 plex plex 77791232 Feb 21 16:42 com.plexapp.plugins.library.db
-rw-r--r-- 1 plex plex 77488128 Feb 10 02:00 com.plexapp.plugins.library.db-2019-02-10
-rw-r--r-- 1 plex plex 77897728 Feb 13 02:00 com.plexapp.plugins.library.db-2019-02-13
-rw-r--r-- 1 plex plex 77538304 Feb 16 02:03 com.plexapp.plugins.library.db-2019-02-16
-rw-r--r-- 1 plex plex 78353408 Feb 19 02:03 com.plexapp.plugins.library.db-2019-02-19
-rwxrwxr-x 1 plex plex 77961216 Feb 13 17:58 com.plexapp.plugins.library.db.backup21319
-rwxr-xr-x 1 plex plex 77719552 Feb 21 12:53 com.plexapp.plugins.library.db.backup22119
-rwxrwxr-x 1 plex plex 77786112 Feb 21 13:47 com.plexapp.plugins.library.db.dbsyc.bak
-rwxrwxr-x 1 plex plex 32768 Feb 21 16:43 com.plexapp.plugins.library.db-shm
-rwxrwxr-x 1 plex plex 40904 Feb 21 16:43 com.plexapp.plugins.library.db-wal
-rwxrwxr-x 1 plex plex 655360 Feb 21 16:42 com.plexapp.plugins.trakttv.db
-rwxrwxr-x 1 plex plex 32768 Feb 21 16:42 com.plexapp.plugins.trakttv.db-shm
-rwxrwxr-x 1 plex plex 4144752 Feb 21 16:42 com.plexapp.plugins.trakttv.db-wal
and here is my remote one
-rwxrwxrwx 1 plex plex 69632 Feb 21 18:48 com.plexapp.dlna.db
-rwxrwxrwx 1 plex plex 32768 Feb 21 18:48 com.plexapp.dlna.db-shm
-rwxrwxrwx 1 plex plex 292552 Feb 21 18:48 com.plexapp.dlna.db-wal
-rwxrwxrwx 1 plex plex 7418880 Jan 28 18:03 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 plex plex 7418880 Feb 10 02:01 com.plexapp.plugins.library.blobs.db-2019-02-10
-rw-r--r-- 1 plex plex 7418880 Feb 13 02:01 com.plexapp.plugins.library.blobs.db-2019-02-13
-rw-r--r-- 1 plex plex 7418880 Feb 16 02:01 com.plexapp.plugins.library.blobs.db-2019-02-16
-rw-r--r-- 1 plex plex 7418880 Feb 19 02:03 com.plexapp.plugins.library.blobs.db-2019-02-19
-rwxrwxrwx 1 plex plex 32768 Feb 21 18:48 com.plexapp.plugins.library.blobs.db-shm
-rwxrwxrwx 1 plex plex 0 Feb 21 18:48 com.plexapp.plugins.library.blobs.db-wal
-rwxrwxrwx 1 plex plex 91483136 Feb 21 21:05 com.plexapp.plugins.library.db
-rw-r--r-- 1 plex plex 90358784 Feb 10 02:01 com.plexapp.plugins.library.db-2019-02-10
-rw-r--r-- 1 plex plex 90683392 Feb 13 02:01 com.plexapp.plugins.library.db-2019-02-13
-rw-r--r-- 1 plex plex 91127808 Feb 16 02:01 com.plexapp.plugins.library.db-2019-02-16
-rw-r--r-- 1 plex plex 91426816 Feb 19 02:03 com.plexapp.plugins.library.db-2019-02-19
-rw-r--r-- 1 plex plex 90930176 Feb 13 23:01 com.plexapp.plugins.library.db.backup21319
-rw-r--r-- 1 plex plex 91378688 Feb 21 17:55 com.plexapp.plugins.library.db.backup22119
-rwxrwxrwx 1 plex plex 87508992 Jan 29 17:32 com.plexapp.plugins.library.db.broken
-rw------- 1 plex plex 90930176 Feb 13 23:05 com.plexapp.plugins.library.db.dbsyc.bak
-rwxrwxrwx 1 plex plex 32768 Feb 21 21:44 com.plexapp.plugins.library.db-shm
-rwxrwxrwx 1 plex plex 1054320 Feb 21 21:44 com.plexapp.plugins.library.db-wal
-rwxrwxrwx 1 plex plex 4874240 Feb 21 18:39 com.plexapp.plugins.trakttv.db
-rwxrwxrwx 1 plex plex 32768 Feb 21 18:48 com.plexapp.plugins.trakttv.db-shm
-rwxrwxrwx 1 plex plex 4144752 Feb 21 18:48 com.plexapp.plugins.trakttv.db-wal
-rwxrwxrwx 1 plex plex 78763525 Jan 29 17:41 dump.sql
-rwxrwxrwx 1 plex plex 0 Jan 29 16:28 .fuse_hidden000000130000000a```
for the plex user branch
- As my normal user, ran
sshfs -o allow_other,IdentityFile=/home/username/.ssh/id_rsa -p 22 [email protected]:"/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/" /media/remoteuser sudo -u plex -s
./plex-db-sync \
--plex-db-1 "/media/remoteuser/com.plexapp.plugins.library.db" \
--plex-start-1 "ssh -oStrictHostKeyChecking=no -i /home/username/.ssh/id_rsa [email protected] service plexmediaserver start" \
--plex-stop-1 "ssh -oStrictHostKeyChecking=no -i /home/username/.ssh/id_rsa [email protected] service plexmediaserver stop" \
--plex-db-2 "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" \
--plex-start-2 "service plexmediaserver start" \
--plex-stop-2 "service plexmediaserver stop" \
--backup true
which asked for remote authentication
Stopping Plex on Server 1... [email protected]'s password:
as well as local authentication
Stopping Plex on Server 2... ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'plexmediaserver.service'.
Authenticating as: username
Password:
==== AUTHENTICATION COMPLETE ===
Then I got this
Checking for changes... sudo: unknown user: 116
sudo: unable to initialize policy plugin
sudo: unknown user: 116
sudo: unable to initialize policy plugin
sudo: unknown user: 116
sudo: unable to initialize policy plugin
sudo: unknown user: 116
sudo: unable to initialize policy plugin
None found
and then it starting things back up, asking for the same authentication
After the remote mount, can you show me the output of the below command when run from the machine you are running plex-db-sync from?
ls -ld "/media/remoteuser/com.plexapp.plugins.library.db" | awk '{print $3}'
I think I need to pull the user from both DBs rather than one. You're plex user is likely 116 on the remote server, but another UID locally.
I think you are getting authentication requests because you are not running plex-db-sync as root, and you are using remoteuser on the remote host, so restarting the services requires it. You would need to make sure your user on each machine is authorized to restart services.
ls -ld "/media/remoteuser/com.plexapp.plugins.library.db" | awk '{print $3}' got 116 as you expect
id -u plex got me 113 locally
but we're saying that doesn't matter if I'm using userlocal and userremote. From what I'm seeing (more on the linux n00b side) is that I need to add to the sudoers file with sudo visudo. I saw something like plex ALL=(ALL) NOPASSWD: systemctl stop plexmediaserver, but when I try to save it says there's a syntax error. Easy error or a better way out there?
I'm on ubuntu 18.04.02 btw
@Fmstrat any ideas on how to move forward?