Add 'PlexServer Backup.sh'
This commit is contained in:
26
PlexServer Backup.sh
Normal file
26
PlexServer Backup.sh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/185473/1388019
|
||||||
|
|
||||||
|
lockfile="/tmp/duplicacy.lock"
|
||||||
|
LOGFILE="/var/log/duplicacy/plexmediaserverMetadata_$(/bin/date +%Y%m%d-%H%M%S).log"
|
||||||
|
|
||||||
|
|
||||||
|
if [ -e ${lockfile} ] && kill -0 `cat ${lockfile}`; then
|
||||||
|
echo "duplicacy backup already running" >> ${LOGFILE}
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# make sure the lockfile is removed when we exit and then claim it
|
||||||
|
trap "rm -f ${lockfile}; exit" INT TERM EXIT
|
||||||
|
echo $$ > ${lockfile}
|
||||||
|
|
||||||
|
# run the backup
|
||||||
|
cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server
|
||||||
|
/bin/duplicacy -verbose -log backup -stats >> ${LOGFILE} 2>&1
|
||||||
|
|
||||||
|
# compress the logs
|
||||||
|
/bin/gzip $(/bin/dirname ${LOGFILE})/*.log
|
||||||
|
|
||||||
|
# clean up lockfile
|
||||||
|
rm -f ${lockfile}
|
||||||
Reference in New Issue
Block a user