From d00acd9c7eb190e6392bad0b69520fd478cb5c66 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 20 Nov 2013 22:31:59 +0000 Subject: [PATCH] Updated backup feature Backup feature now works better. Does not use the full path in the archive anymore. Also fixed the exclusions not working correctly meaning it was backing up any previously created backups --- CounterStrike/csserver | 4 +-- CounterStrikeGlobalOffensive/csgoserver | 4 +-- CounterStrikeSource/cssserver | 4 +-- DayOfDefeatSource/dodsserver | 4 +-- HalfLife2Deathmatch/hl2dmserver | 4 +-- KillingFloor/kfserver | 4 +-- Left4Dead2/l4d2server | 4 +-- Mumble/mumbleserver | 47 ++++++++++++++++++++++++ NaturalSelection2/ns2server | 6 ++-- NoMoreRoomInHell/nmrihserver | 4 +-- RedOrchestra/roserver | 4 +-- TeamFortress2/tf2server | 4 +-- TeamSpeak3/ts3server | 7 ++-- TheHiddenSource/thsserver | 48 +++++++++++++++++++++++++ UnrealTournament2004/ut2k4server | 4 +-- UnrealTournament99/ut99server | 4 +-- 16 files changed, 125 insertions(+), 31 deletions(-) diff --git a/CounterStrike/csserver b/CounterStrike/csserver index a6abd908a..5923dfd89 100644 --- a/CounterStrike/csserver +++ b/CounterStrike/csserver @@ -33,7 +33,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/cstrike/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" # Server Details servername$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -218,7 +218,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/CounterStrikeGlobalOffensive/csgoserver b/CounterStrikeGlobalOffensive/csgoserver index ff49458d2..7e7c2e060 100644 --- a/CounterStrikeGlobalOffensive/csgoserver +++ b/CounterStrikeGlobalOffensive/csgoserver @@ -34,7 +34,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/csgo/cfg/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" # Server Details servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -219,7 +219,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/CounterStrikeSource/cssserver b/CounterStrikeSource/cssserver index 580cff6e1..b188f222e 100644 --- a/CounterStrikeSource/cssserver +++ b/CounterStrikeSource/cssserver @@ -34,7 +34,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/cstrike/cfg/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" # Server Details servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -219,7 +219,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/DayOfDefeatSource/dodsserver b/DayOfDefeatSource/dodsserver index af2567781..e4857aa9d 100644 --- a/DayOfDefeatSource/dodsserver +++ b/DayOfDefeatSource/dodsserver @@ -34,7 +34,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/dod/cfg/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') rcon=$(grep -s rcon_password ${servercfg} | sed 's/rcon_password //g'|sed 's/"//g') @@ -218,7 +218,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/HalfLife2Deathmatch/hl2dmserver b/HalfLife2Deathmatch/hl2dmserver index b23866a1d..40bd693b8 100644 --- a/HalfLife2Deathmatch/hl2dmserver +++ b/HalfLife2Deathmatch/hl2dmserver @@ -34,7 +34,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/hl2mp/cfg/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" # Server Details servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -219,7 +219,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/KillingFloor/kfserver b/KillingFloor/kfserver index 1ff8b9a1a..5ccdc00f5 100644 --- a/KillingFloor/kfserver +++ b/KillingFloor/kfserver @@ -24,8 +24,8 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/System" -backupdir="${rootdir}/backups" compressedmapsdir="${rootdir}/Maps-Compressed" +backupdir="backups" # Server Details servicename="kf-server" @@ -286,7 +286,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/Left4Dead2/l4d2server b/Left4Dead2/l4d2server index cc6ba0f9c..a84a37d51 100644 --- a/Left4Dead2/l4d2server +++ b/Left4Dead2/l4d2server @@ -34,7 +34,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/left4dead2/cfg/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" # Server Details servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -219,7 +219,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/Mumble/mumbleserver b/Mumble/mumbleserver index 11d5cb5ac..6c6fe4570 100644 --- a/Mumble/mumbleserver +++ b/Mumble/mumbleserver @@ -21,6 +21,7 @@ rootdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/murmur" ini="murmur.ini" +backupdir="backups" # Logging logdir="${rootdir}/log" @@ -72,6 +73,52 @@ if [ ! -e ${filesdir}/${ini} ]; then fi } +fn_backupserver(){ +fn_rootcheck +fn_syscheck +backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" +echo "" +echo "${gamename} Backup" +echo "============================" +echo "" +echo "The following backup will be created." +echo "" +echo "${backupdir}/${backupname}.tar.gz" +echo "" +while true; do + read -p "Continue? [y/N]" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) echo Exiting; return 1 ;; + * ) echo "Please answer yes or no.";; +esac +done +tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep ${servicename}|wc -l) +if [ ${tmuxwc} -eq 1 ];then + echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running" + while true; do + read -p "Would you like to stop ${servicename} while running the backup? [y/N]" yn + case $yn in + [Yy]* ) fn_stopserver;break;; + [Nn]* ) break;; + * ) echo "Please answer yes or no.";; + esac + done +fi +echo -en "[ .... ] Starting ${servicename}: ${servername} backup" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername} backup" >> ${scriptlog} +sleep 0.5 +echo -en "\r[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername} backup" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} backup" >> ${scriptlog} +sleep 1 +echo -en "\n" +cd ${rootdir} +mkdir ${backupdir} > /dev/null 2>&1 +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * +echo -en "\r${servicename} backup complete" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} +} + fn_distro(){ arch=$(uname -m) kernel=$(uname -r) diff --git a/NaturalSelection2/ns2server b/NaturalSelection2/ns2server index ee62edce0..0f386f57b 100644 --- a/NaturalSelection2/ns2server +++ b/NaturalSelection2/ns2server @@ -42,7 +42,7 @@ engine="spark" rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" -backupdir="${rootdir}/backups" +backupdir="backups" # Logging logdays="7" @@ -223,7 +223,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } @@ -239,7 +239,7 @@ echo "Ports the server is currently using" echo "" echo "DIRECTION DESCRIPTION PORT" echo "INBOUND Game/Rcon Port ${port}" -echo "INBOUND WebAdmin ${webadminport}" +echo "INBOUND WebAdmin ${webadminport}" echo "" echo "${servername} WebAdmin" echo "=======================" diff --git a/NoMoreRoomInHell/nmrihserver b/NoMoreRoomInHell/nmrihserver index 4e2a2291f..885651db6 100644 --- a/NoMoreRoomInHell/nmrihserver +++ b/NoMoreRoomInHell/nmrihserver @@ -38,7 +38,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/nmrih/cfg/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" # Server Details servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -223,7 +223,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/RedOrchestra/roserver b/RedOrchestra/roserver index a56b5c8d3..303d64ec2 100644 --- a/RedOrchestra/roserver +++ b/RedOrchestra/roserver @@ -24,8 +24,8 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/system" -backupdir="${rootdir}/backups" compressedmapsdir="${rootdir}/Maps-Compressed" +backupdir="backups" # Server Details servicename="ro-server" @@ -285,7 +285,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/TeamFortress2/tf2server b/TeamFortress2/tf2server index 17d05dc2a..e7133b715 100644 --- a/TeamFortress2/tf2server +++ b/TeamFortress2/tf2server @@ -34,7 +34,7 @@ rootdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/tf/cfg/${servicename}.cfg" -backupdir="${rootdir}/backups" +backupdir="backups" # Server Details servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -219,7 +219,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/TeamSpeak3/ts3server b/TeamSpeak3/ts3server index 694923196..d55fd6ffb 100644 --- a/TeamSpeak3/ts3server +++ b/TeamSpeak3/ts3server @@ -21,7 +21,7 @@ servicename="ts3-server" rootdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" filesdir="${rootdir}/serverfiles" ini="${servicename}.ini" -backupdir="${rootdir}/backups" +backupdir="backups" # Logging logdays="7" @@ -120,7 +120,6 @@ while true; do * ) echo "Please answer yes or no.";; esac done - fn_status if [ "$ts3status" = "Server is running" ]; then echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running" @@ -142,7 +141,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } @@ -322,7 +321,7 @@ case "$1" in backup) fn_backupserver;; monitor) - fn_monitorserver;; + fn_monitorserver;; email-test) fn_emailtest;; *) diff --git a/TheHiddenSource/thsserver b/TheHiddenSource/thsserver index a1c943577..d8c6cfd07 100644 --- a/TheHiddenSource/thsserver +++ b/TheHiddenSource/thsserver @@ -31,6 +31,7 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" servercfg="${filesdir}/hidden/cfg/${servicename}.cfg" +backupdir="backups" # Server Details servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') @@ -174,6 +175,53 @@ else fi } +fn_backupserver(){ +fn_rootcheck +fn_syscheck +backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" +echo "" +echo "${gamename} Backup" +echo "============================" +echo "" +echo "The following backup will be created." +echo "" +echo "${backupdir}/${backupname}.tar.gz" +echo "" +while true; do + read -p "Continue? [y/N]" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) echo Exiting; return 1 ;; + * ) echo "Please answer yes or no.";; +esac +done +tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep ${servicename}|wc -l) +if [ ${tmuxwc} -eq 1 ];then + echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running" + while true; do + read -p "Would you like to stop ${servicename} while running the backup? [y/N]" yn + case $yn in + [Yy]* ) fn_stopserver;break;; + [Nn]* ) break;; + * ) echo "Please answer yes or no.";; + esac + done +fi +echo -en "[ .... ] Starting ${servicename}: ${servername} backup" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername} backup" >> ${scriptlog} +sleep 0.5 +echo -en "\r[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername} backup" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} backup" >> ${scriptlog} +sleep 1 +echo -en "\n" +cd ${rootdir} +mkdir ${backupdir} > /dev/null 2>&1 +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * +echo -en "\r${servicename} backup complete" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} +} + + fn_backupserver(){ fn_rootcheck fn_syscheck diff --git a/UnrealTournament2004/ut2k4server b/UnrealTournament2004/ut2k4server index afa4a90f4..948e0fdb9 100644 --- a/UnrealTournament2004/ut2k4server +++ b/UnrealTournament2004/ut2k4server @@ -17,8 +17,8 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/System" -backupdir="${rootdir}/backups" compressedmapsdir="${rootdir}/Maps-Compressed" +backupdir="backups" # Server Details servicename="ut2k4-server" @@ -249,7 +249,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} } diff --git a/UnrealTournament99/ut99server b/UnrealTournament99/ut99server index 1d27babff..211b64a5b 100644 --- a/UnrealTournament99/ut99server +++ b/UnrealTournament99/ut99server @@ -17,8 +17,8 @@ rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/System" -backupdir="${rootdir}/backups" compressedmapsdir="${rootdir}/Maps-Compressed" +backupdir="backups" # Server Details servicename="ut99-server" @@ -239,7 +239,7 @@ sleep 1 echo -en "\n" cd ${rootdir} mkdir ${backupdir} > /dev/null 2>&1 -tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} ${rootdir} +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * echo -en "\r${servicename} backup complete" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog} }