How to automate the backing up of my Plex Media Server
A Bash Script
I wanted to automate this process. If I didn’t, it probably wouldn’t get done.
This script was adapted from another GitHub Gist that I found here.
You will probably need to modify the following variables.
Pay attention to lines 17 ~ 21. These refer to the possibility that your script may not complete if your machine can go to sleep. As it suggests use the ‘caffeinate’ command to prevent your machine from sleeping during backup. It will be able to sleep after the script completes.
Don’t forget to give the script execution permission using ‘chmod +x scriptname’
Install a cronjob under your user account using:
The contents of my cronjob
SHELL=/bin/bash 06 02 * * Sun /usr/bin/caffeinate $HOME/bin/plexbackup.sh
- You need a SHELL set for the cronjob to run the command.
- The script runs weekly on Sunday from 6:02am
- It uses
caffeinateso that the machine does not sleep during backup. I do not have my sleep value set to 0 on this machine.
- My backup script is located in my home directory under the folder bin