Skip to content

Instantly share code, notes, and snippets.

@gryte
Last active January 2, 2019 12:27
Show Gist options
  • Save gryte/2dde6089041e8b25902e69cfd5b5874c to your computer and use it in GitHub Desktop.
Save gryte/2dde6089041e8b25902e69cfd5b5874c to your computer and use it in GitHub Desktop.
install_pms_centos_7

on plexserver, create directories

create scripts directory

sudo mkdir /scripts

create backup directory

sudo mkdir /backups

on plexserver, create backup scripts

create level 0 backup script

#!/bin/bash
#Purpose = Backup of Important Data - Level 0
#Created on 28-02-2016
#Modified on 2016-11-01
#Author = Hafiz Haider
#Contributor = Adam Linkous
#Version 2.1
#START
FILENAME=plexserverbackup-full.tar.gz                                                                 # Here i define Backup file name format.
SRCDIR=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/                      # Location of Important Data Directory (Source of backup).
DESDIR=/backups                                                                                        # Destination of backup file.
SNF=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/plexdata.snar            # Snapshot file name and location
EXCLDCRSH=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Crash\ Reports     # Exclude Crash directory
EXCLDLOG=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Logs                # Exclude Logs directory

rm -f "$SNF" > /dev/null                                                                               # remove any previous snapshots

tar -cvf "$DESDIR"/"$FILENAME" -g "$SNF" "$SRCDIR" --exclude="$EXCLDCRSH" --exclude="$EXCLDLOG"        # Backup Command

cp "$SNF" "$SNF".bak                                                                                   # Create copy of full snapshot

#END 

create level 1 backup script

#!/bin/bash
#Purpose = Backup of Important Data - Level 1
#Created on 28-02-2016
#Modified on 2016-11-01
#Author = Hafiz Haider
#Contributor = Adam Linkous
#Version 2.1
#START
FILENAME=plexserverbackup-incremental.tar.gz                                                                 # Here i define Backup file name format.
SRCDIR=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/                      # Location of Important Data Directory (Source of backup).
DESDIR=/backups                                                                                        # Destination of backup file.
SNF=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/plexdata.snar            # Snapshot file name and location
EXCLDCRSH=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Crash\ Reports     # Exclude Crash directory
EXCLDLOG=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Logs                # Exclude Logs directory

cp "$SNF".bak "$SNF"                                                                                   # Ensure snapshot is copy of full

tar -cvf "$DESDIR"/"$FILENAME" -g "$SNF" "$SRCDIR" --exclude="$EXCLDCRSH" --exclude="$EXCLDLOG"    # Backup Command
#END 

schedule backup jobs as root

edit crontab as root

sudo vi /etc/crontab

schedule both the full and incremental backup jobs

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

# perform full backup every 2 weeks at 1:00am
  0  1  0-28/14  *  * root /scripts/plexserverbackup_full.sh
  
# perform incremental backup every night at 1:05am
  5  1  *  *  * root /scripts/plexserverbackup_incremental.sh

restore from backups

clean up old directory if exists

sudo rm -rf /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/

restore full backup

sudo tar -xzpf /backups/plexserverbackup-full.tar.gz

restore from incremental backup (only if the incremental is actually more recent than the full)

sudo tar --incremental -xzpf /backups/plexserverbackup-incremental.tar.gz

citations

main article

configure centos 7.x

login as root and update packages

yum update

add plex user

  • not neccessary since rpm creates this for us
  • creating this user manually actually breaks the install

lockdown root - prevent remote ssh login

vi /etc/ssh/sshd_config

PermitRootLogin no

downloading and installing plex media server

log in as non-root user

install wget

sudo yum install wget

create downloads dir

mkdir ~/Downloads
cd ~/Downloads

download latest centos 7.x rpm as of 2017-03-24

wget https://downloads.plex.tv/plex-media-server/1.4.4.3495-edef59192/plexmediaserver-1.4.4.3495-edef59192.x86_64.rpm

install rpm

sudo yum localinstall plexmediaserver-1.4.4.3495-edef59192.x86_64.rpm

start plex

sudo systemctl start plexmediaserver.service

temporarily disable firewall to check service

  • concern needing further research - this step wasn't necessary since the service wasn't running

check that the web browser can hit the plex service

http://<plexserver_ip>:32400/web/

reboot the node and ensure the service starts up on its own

sudo reboot

mount usb drive to proxmox plex

on proxmox server connect usb drive, and pass USB device ID to plex server

find device ID

lsusb

assign it to the plex server vm100

qm set 100 -usb0 host=4971:1011

shutdown vm (if running) and start it again

on plex server, install cifs-utils to support smb

  • wound up not needing it but we'll keep it anyway
sudo yum install cifs-utils

create directory to mount smb share

mkdir /mnt/usb
mkdir /mnt/usb/media

enable ntfs support

yum install epel-release
yum install ntfs-3g

mount the usb drive

mount /dev/sda1 /mnt/usb/media

update fstab

vi /etc/fstab

/dev/sda1    /mnt/usb/media    ntfs    defaults    0 0

restart the server to ensure the share mounts

share the usb drive mounted on plexserver with torrentserver using nfs

on plexserver install nfs items

yum install nfs-utils nfs-utils-lib

start rpcbind and nfs services

systemctl enable rpcbind.service
systemctl start rpcbind.service
systemctl enable nfs-server.service
systemctl start nfs-server.service

edit /etc/exports

vi /etc/exports

/mnt/usb/media/Adam/Movies/         <delugeserver_ip>(rw,sync,no_root_squash,no_subtree_check)
"/mnt/usb/media/Adam/TV Shows/"     <delugeserver_ip>(rw,sync,no_root_squash,no_subtree_check)
/mnt/usb/media/Adam/Movies/         <couchserver_ip>(rw,sync,no_root_squash,no_subtree_check)
"/mnt/usb/media/Adam/TV Shows/"     <sonarrserver_ip>(rw,sync,no_root_squash,no_subtree_check)
/mnt/usb/media/Adam/Movies/         <dockerserver_ip>(rw,sync,no_root_squash,no_subtree_check)
"/mnt/usb/media/Adam/TV Shows/"     <dockerserver_ip>(rw,sync,no_root_squash,no_subtree_check)

export directories

sudo exportfs -a

on torrentserver, install nfs utilities

yum install nfs-utils

create directories for nfs shares

mkdir -p /mnt/nfs/movies
mkdir -p /mnt/nfs/tvshows

mount the directories

mount <plexserver_ip>:/mnt/usb/media/Adam/Movies/ /mnt/nfs/movies
mount <plexserver_ip>:"/mnt/usb/media/Adam/TV Shows/" /mnt/nfs/tvshows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment