From adf964c95f81b66a95e7d5c2d2bab23835197e1d Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 9 Jul 2023 10:41:59 -0500 Subject: [PATCH] update --- defaults.inc | 14 +++++++------- mm-scripts.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/defaults.inc b/defaults.inc index 1acc8f1..9802c4e 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERS='3.8.255-07012023' +VERS='3.8.260-07012023' MMFOLDER="/opt/idssys/mediamanager" TMPFOLDER="${MMFOLDER}/.tmp" @@ -38,10 +38,10 @@ MM_SERVICES['ombi']='Ombi (Download Requester)' MM_SERVICES['snap.overseerr.daemon']='Overseerr (Download Requester)' MM_SERVICES['qbittorrent']='qBittorrent (Torrent Downloader)' MM_SERVICES['prowlarr']='Prowlarr (Torrent Indexing Manager)' -MM_SERVICES['radarr']='Radarr (Movie Manager)' -MM_SERVICES['radarr3d']='Radarr3D (3D Movie Manager)' -MM_SERVICES['readarr']='Readarr (Book Manager)' -MM_SERVICES['sonarr']='Sonarr (TV Show Manager)' +MM_SERVICES['radarr']='Radarr (Movies Manager)' +MM_SERVICES['radarr3d']='Radarr3D (3D Movies Manager)' +MM_SERVICES['readarr']='Readarr (Books Manager)' +MM_SERVICES['sonarr']='Sonarr (TV Shows Manager)' MM_SERVICES['snap.tautulli.tautulli']='Tautulli (Plex Stats)' declare -A MM_SERVICE_PORTS @@ -80,8 +80,8 @@ declare -A MM_UPDATE_REPO #MM_UPDATE_REPO['ombi']='Ombi-app' MM_UPDATE_REPO['ombi']='systemd' MM_UPDATE_REPO['radarr']='radarr' -MM_UPDATE_REPO['sonarr']='sonarr' -# MM_UPDATE_REPO['sonarr']='systemd' +# MM_UPDATE_REPO['sonarr']='sonarr' +MM_UPDATE_REPO['sonarr']='systemd' MM_UPDATE_REPO['lidarr']='lidarr' MM_UPDATE_REPO['jackett']='jackett' MM_UPDATE_REPO['bazarr']='morpheus65535' diff --git a/mm-scripts.sh b/mm-scripts.sh index 26f703d..e40d187 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -1053,6 +1053,50 @@ WantedBy=multi-user.target } SERVICEBACKUP(){ + type pv >/dev/null 2>&1 || sudo apt -y install pv + usrvc=${1} + msg="Stopping Service and Backing Up"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done + echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" + /bin/systemctl stop ${usrvc} >> ${LOGFOLDER}/update.${usrvc} + [ "${usrvc}" == "radarr" ] && /bin/systemctl stop radarr3d >> ${LOGFOLDER}/update.${usrvc} + + BACKUPDIR=/opt/Backups/${usrvc} + [ ! -d ${BACKUPDIR} ] && mkdir -p ${BACKUPDIR} + [ "${MM_SERVICE_APP[$usrvc]}" != "" ] && APPBAKFOLDER=${MM_SERVICE_APP[$usrvc]} || APPBAKFOLDER=/opt/${usrvc^} + + if [ $(expr `date +%s` - $(stat -c %Y ${LOGFOLDER}/update.${usrvc})) -gt 7776000 ] || ([ ! -f ${BACKUPDIR}/cfg.tgz ] && [ "${MM_SERVICE_CFG[${usrvc}]}" != "" ] && [ -d ${MM_SERVICE_CFG[${usrvc}]} ]) || ([ ! -f ${BACKUPDIR}/app.tgz ] && [ "${MM_SERVICE_APP[$usrvc]}" != "none" ]); then + NEWER="" + NOW=`date +%d-%b` + if [ "${MM_SERVICE_APP[$usrvc]}" != "none" ]; then + echo ${NOW} > ${BACKUPDIR}/app-full-date + /bin/tar ${NEWER} cf - -C ${APPBAKFOLDER}/* | pv -s $(du -sb ${APPBAKFOLDER} | awk '{print $1}') | gzip > ${BACKUPDIR}/app.tgz + fi + if [ "${MM_SERVICE_CFG[${usrvc}]}" != "" ] && [ -d ${MM_SERVICE_CFG[${usrvc}]} ]; then + echo ${NOW} > ${BACKUPDIR}/cfg-full-date + /bin/tar ${NEWER} cf - -C ${MM_SERVICE_CFG[${usrvc}]}/* | pv -s $(du -sb ${MM_SERVICE_CFG[${usrvc}]} | awk '{print $1}') | gzip > ${BACKUPDIR}/cfg.tgz + fi + + else + if [ "${MM_SERVICE_APP[$usrvc]}" != "none" ]; then + NEWER="--newer `cat ${BACKUPDIR}/app-full-date`" + /bin/tar $NEWER cf - -C ${APPBAKFOLDER}/* | pv -s $(du -sb ${APPBAKFOLDER} | awk '{print $1}') | gzip > ${BACKUPDIR}/app.${NOW}.tgz + fi + if [ "${MM_SERVICE_CFG[${usrvc}]}" != "" ] && [ -d ${MM_SERVICE_CFG[${usrvc}]} ]; then + NEWER="--newer `cat ${BACKUPDIR}/cfg-full-date`" + /bin/tar $NEWER cf - -C ${MM_SERVICE_CFG[${usrvc}]}/* | pv -s $(du -sb ${MM_SERVICE_CFG[${usrvc}]} | awk '{print $1}') | gzip > ${BACKUPDIR}/cfg.${NOW}.tgz + fi + fi + + for BAKFILE in ${BACKUPDIR}/app.*.tgz; do + [ ${BACKUPDIR}/app.tgz -nt ${BAKFILE} ] && rm -f ${BAKFILE} + done + for BAKFILE in ${BACKUPDIR}/cfg.*.tgz; do + [ ${BACKUPDIR}/cfg.tgz -nt ${BAKFILE} ] && rm -f ${BAKFILE} + done + + echo -e "${idsCL[Green]}Done${idsCL[Default]}" +} +SERVICEBACKUP.old(){ usrvc=${1} msg="Stopping Service and Backing Up"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}"