Server Version#: 1.24.4.5081
Hi all,
I have a HP Proliant N54 running PMS Ubuntu 20.04.2 LTS.
I believe that Plex does backups internally every three days. What I want to do is to set up backup to a remote NAS. Seems pointless doing backups to the same disk, if the disk dies the backup is gone with it.
Is there a script of some sort to do this? I don’t think I can just add the location in to the ‘Backup Directory’ under Scheduled Tasks. I have tried that and I don’t see any backup files appearing in the remote directory.
Please note that I am only looking to back up the Plex database and settings, the media is stored somewhere else totally different.
Oh sure, I can write you the whole procedure… But what would you learn?
LOL
Key points.
Run the script using crontab (as root)
In the script (customize/finish as needed):
#!/bin/bash
# Note: This script assumes running as root in order to make the backup
# Mount NAS folders here if needed (fill in the details)
# mount host:/sharename /mountpoint
# Stop Plex
systemctl stop plexmediaserver
# Perform backup (set the output path from '/nas/backups' to whatever you need)
cd /var/lib/plexmediaserver
tar cf "/nas/backups/PlexBackup-$(date +'%F').tar" ./Library
# All done, start plex
systemctl start plexmediaserver
Read up on crontab.
you’ll want sudo crontab to edit the root user’s crontab jobs file.
The output format for the files will be: PlexBackup-YYYY-MM-DD.tar
Will that work?
Note: This is verification of what date +'%F' will return
Hi,
I have had a go at this and of course, I am looking for some more advice.
Here is what I did for a script:
leif@HP-ProLiant-MicroServer:~$ cat pmsbackup-external
#!/bin/bash
systemctl stop plexmediaserver
cd /var/lib/plexmediaserver
tar cf 192.168.1.5:/Multimedia/Backup_files-$(date +’%F’).tar .Library
systemctl start plexmediaserver
Problem No 1:
Here is what happen when try and run that script:
leif@HP-ProLiant-MicroServer:~$ pmsbackup-external pmsbackup-external: command not found
I have to use sh to get the script to run. I thought that having the #!/bin/bash in the script would fix that?
Problem No 2: How can I get around the problem with ‘Authentication is required’ if I want to automate this?
Problem No 3: I have created a user ‘leif’ in the NAS but the authentication fails saying ‘Permission Denied’. I have no idea why it says that…I know that this is not Plex related so I am looking for good ideas why this can be? I know that the user is valid, I can log in to the NAS via the web page no problems and that use has Read / Write access to the backup folder.
Thanks heaps in advance…
Leif
leif@HP-ProLiant-MicroServer:~$ sh pmsbackup-external
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop ‘plexmediaserver.service’.
Multiple identities can be used for authentication:
Thank you so much! This GREAT feedback. I think I may have mounted that folder already now that I think about, most likely when I mounted all the media folders.
Another question; I read somewhere what need to be backed up - /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases.
Is that not correct? I added the folder that you said which I guess adds a few more sub-folders but otherwise the same.
Problem 1:
my file is in /home/leif.
Here is my PATH:
leif@HP-ProLiant-MicroServer:~$ echo $PATH
/home/leif/bin:/home/leif/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/u sr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Am I missing something?
Problem 2:
The first step looks like it needs manual intervention, please see below. Can I get around that?
Authentication is required to stop ‘plexmediaserver.service’.
Multiple identities can be used for authentication:
leif, (leif)
L Lundberg, (llundberg)
Choose identity to authenticate as (1-2): 1
Password:
Hi me again,
I am still working on this script and I have tried to just back up locally first to try and resolve issues with access to the other location.
I try this:
leif@HP-ProLiant-MicroServer:~$ sudo systemctl stop plexmediaserver
[sudo] password for leif:
leif@HP-ProLiant-MicroServer:~$ tar cf Downloads/plexbu.tar /var/lib/plexmediaserver
And I get this (plus many more ‘Permission denied’, I just copied the first to demonstrate the problem). Why do I get the Permission denied?
Please help, I have nowhere else to turn.
tar: Removing leading `/’ from member names
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Preferences.xml: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/CloudAccount.dat: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/certificate.p12: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/ca.crt: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/CloudAccess.dat: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/3c/3c1886943a2e6c6d436cbb57382dbf5d328960e2.jpg: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/80/808129cfc4af9799f73d3bdd55b3d59ef7192d7b.jpg: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/d2/d20a8c1601a1a8facc7b25cb2f3735827a5ba0cc.png: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/dd/dd48254469847a37e81af334403590fb6b815270.jpg: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/c8/c8901481ac00cfedfc4a23133e930a37c2df8459.jpg: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/26/266c02aabb996068fced7a16c03509b1290d881b.jpg: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/a1/a145abbb1d17c835232a38a0929328259b7df774.png: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/7f/7fa8d8cfcfc858ba2f0ce807316a5ce0e4aac14a.jpg: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/f9/f97ac7d1835a4f3a37b19ab76cfeea8e4e4fe733.jpg: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Cache/PhotoTranscoder/ab/ab96e8964b94322a84d0f7fd2490bb16259396ac.png: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Plug-in Support/Metadata Combination/com.plexapp.agents.lastfm/Artists.xml: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/Library.old/Application Support/Plex Media Server/Codecs/.device-id: Cannot open: Permission denied
tar: /var/lib/plexmediaserver/.ssh: Cannot open: Permission denied
btw. Will Plex ever allow Backup of all settings and data internally? Ie. to Google drive, etc customers own server. thumbs, settings, and other stuff is not that big data to backup.
BUT you could make is so that you could backup ALL with checkboxes… just choose what to backup and tell customer that its xxTB of data… =)
Backing up all of PMS and its data , while it’s running, is very unlikely
I say this because:
Backing up a live database, where others could be streaming simultaneously, wouldn’t be a full backup.
There are so many different ways and places to backup externally, programming all of them into PMS would be a big task.
IF PMS did have the most common backup methods available , we come back to the problem of how to backup a live & operational database.
Bottom line, PMS wasn’t designed to back itself up and doing so would be a big task.
On some of the platforms, it’s not possible to have it backup itself because of how those OS’s work.
It would be nice but unfortunately it’s not likely to happen because of the amount of work required for such a minimal return.
Hi me again, I only seem to get time to work on this occasionally, this is why there are time gaps between my posts.
I have created a backup folder on the backup server and tried to mount this:
leif@HP-ProLiant-MicroServer:~$ sudo mount 192.168.1.122:/Backup/plex_backups
mount.nfs: access denied by server while mounting 192.168.1.122:/Backup/plex_backups
Any clues why the failure?
I am so grateful for your help here. If it wasn’t for this forum I would be no where with this.