PMS Database backup to external location - Ubuntu

The syntax is sudo mount source-spec local-directory
which makes this: sudo mount 192.168.1.122:/Backup/plex_backups /some_local_dir

Before we can mount /Backup from the NFS server, we must export it

  1. On the NFS server, make sure the NFS service is running
  2. Edit /etc/exports
  3. Add /Backup *(rw,async,no_subtree_check,no_root_squash)
  4. Save and exit the editor
  5. sudo exportfs -a (to make the NFS server re-read the file)

Now the file system is exported.

Last thing we do is make certain file permissions are open enough to allow mounting of /Backup/plex_backups. Do this by looking on the server . Whichever UID/GID will be writing (typically my UID/GID) should own the directories.

Return to the local host and mount the directory.

When you’re happy with that, you make the mount permanent by adding to /etc/fstab

For reference, (because I’m ‘retentive’ :wink: ), I have it this way:
(/vol = 144TB RAID 6 main volume, /vmssd = 2TB SSD PCIe array)

# New layout
/vmssd        *(rw,async,no_subtree_check,no_root_squash)
/vol          *(rw,async,no_subtree_check,no_root_squash)


/vol/backup   *(rw,async,no_subtree_check,no_root_squash)
/vol/chuck    *(rw,async,no_subtree_check,no_root_squash)
/vol/iso      *(rw,async,no_subtree_check,no_root_squash)
/vol/media    *(rw,async,no_subtree_check,no_root_squash)
/vol/pfsense  *(rw,async,no_subtree_check,no_root_squash)
/vol/plex     *(rw,async,no_subtree_check,no_root_squash)
/vol/primo    *(rw,async,no_subtree_check,no_root_squash)
/vol/software *(rw,async,no_subtree_check,no_root_squash)
/vol/usenet   *(rw,async,no_subtree_check,no_root_squash)
/vol/vmhdd    *(rw,async,no_subtree_check,no_root_squash)
/vol/vtmp     *(rw,async,no_subtree_check,no_root_squash)
/vol/math     *(rw,async,no_subtree_check,no_root_squash)

Thanks again.
I think I have the syntax right:
sudo mount 192.168.1.122:/Backup/plex_backups /mnt/plexbackups
tar cf /mnt/Backup_files-$(date +’%F’).tar .Library

On the NAS, I start vi and open exports file to add the new line:

[llundberg@TS-451 etc]$ vi exports
“/share/MD0_DATA/Multimedia” 192.168.1.20(sec=sys,rw,async,wdelay,insecure,no_subtree_check,no_root_squash,fsid=4ac8a5e687f8c3da5c137e8501c84505)
“/share/MD0_DATA/Public” *(sec=sys,rw,async,wdelay,insecure,no_subtree_check,no_root_squash,fsid=43acc2b9001d3b2cccd436d9235baee0)On the NAS, I start vi and open exports file to add the new line:

[llundberg@TS-451 etc]$ vi exports
“/share/MD0_DATA/Multimedia” 192.168.1.20(sec=sys,rw,async,wdelay,insecure,no_subtree_check,no_root_squash,fsid=4ac8a5e687f8c3da5c137e8501c84505)
“/share/MD0_DATA/Public” *(sec=sys,rw,async,wdelay,insecure,no_subtree_check,no_root_squash,fsid=43acc2b9001d3b2cccd436d9235baee0)

I then try to add a new line here pressing ‘o’, I get this warning message:

exports
W10: Warning: Changing a readonly file
E325: ATTENTION
Found a swap file by the name “/var/tmp/exports.swp”
owned by: llundberg dated: Fri May 13 15:54:58 2022
file name: /etc/exports
modified: YES
user name: llundberg host name: TS-451
process ID: 17604 (still running)
While opening file “exports”
dated: Mon Apr 25 16:11:12 2022

(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.

(2) An edit session for this file crashed.
If this is the case, use “:recover” or “vim -r exports”
to recover the changes (see “:help recovery”).
If you did this already, delete the swap file “/var/tmp/exports.swp”
to avoid this message.

Any hints / tips?
Shall I proceed with editing the Read Only file and if so, is there an easy way of making it Editable instead of Read Only?
This is on the QNAP NAS.

Thanks again.

Update; I hope I did this right - The export file, should that be on the server being backed up?
This server did not have an exports file so I created that file with the line:
"/Backup *(rw,async,no_subtree_check,no_root_squash)
The reason I added the " was because I had seen that in other export file entries on another server. Please let me know if that is wrong.

In any case, after that, I did the leif@HP-ProLiant-MicroServer:~$ sudo exportfs -a:
Reponse:
sudo: exportfs: command not found

Apologies for all this, I am trying and probably getting closer each time. I will not give up on this as long as you keep supporting me.

Thanks again.

This isn’t correct.

Please look at my exports file from the server.

/vol/backup   *(rw,async,no_subtree_check,no_root_squash)
/vol/chuck    *(rw,async,no_subtree_check,no_root_squash)
/vol/iso      *(rw,async,no_subtree_check,no_root_squash)
/vol/media    *(rw,async,no_subtree_check,no_root_squash)

Hi again,
I know it has been a long time, because of work I don’t get much chance to spend enough meaningful time on this.
In any case, some progress; I now have got to the point where I am able to do a back using the command line:
systemctl stop plexmediaserver
sudo tar cf /mnt/plexbackups/Backup_files-$(date +’%F’).tar /var/lib/plexmediaserver/Library
systemctl start plexmediaserver

A big problem was that the NFS wasn’t set up properly on the backup box but that is now sorted. I am doing the mount in fstab and that works.

I have made a shell script:
leif@HP-ProLiant-MicroServer:~$ cat pmsbackup-external.sh
#!/bin/bash
sudo systemctl stop plexmediaserver
sudo tar cf /mnt/plexbackups/Backup_files-$(date +’%F’).tar /var/lib/plexmediaserver/Library
sudo systemctl start plexmediaserver

I now have TWO problems:

  1. The script only runs if I add 'bash ’ in front of the file name. If I don’t do that, I get ‘command not found’. I have made the file executable with chmod u+x pmsbackup-external.sh.
    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:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/leif
    The script resides in /home/leif.

I have researched this until I am blue in the face so I am hoping you can help me with both 1 and 2.

  1. The stop and start plexmediaserver commands needs password authentication. How can I do this in a script?

Thanks in advance.

Update; the script now works without entering ‘bash’ in front. I am somewhat curious because I don’t believe I made any changes.
So the only problem I now need to solve is how to get around the password prompt. I tried the solution you suggested but that didn’t seem to work.
Please help if you can.

Update; I have finally solved the password problem. Took ages to figure out but I finally solved it by using autoexpect in a script that then pawns the actual backup script.
May eventually look at setting up SSH to change this.

I have scheduled a cron job to run every Wednesday at midnight. Fingers crossed.

Now fully solved. I run the cron job as root and as such, I don’t need the Expect file.

In my script:
#!/bin/bash

trap “set +x; sleep 22 set -x”

systemctl stop plexmediaserver
tar cf /mnt/plexbackups/Backup_files-$(date +‘%F’).tar /var/lib/plexmediaserver/Library
systemctl start plexmediaserver

Thank you for your support. I have learnt lots doing this.

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