From 2eea6f5521b3d5772286fc98e0fe565bb23fe940 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Fri, 24 Dec 2021 23:07:00 -0600 Subject: [PATCH] Added backup function --- CentOS/7-Days-To-Die/7D2D-Manage.bash | 47 ++++++++++++--------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/CentOS/7-Days-To-Die/7D2D-Manage.bash b/CentOS/7-Days-To-Die/7D2D-Manage.bash index 1540c58..308f032 100644 --- a/CentOS/7-Days-To-Die/7D2D-Manage.bash +++ b/CentOS/7-Days-To-Die/7D2D-Manage.bash @@ -141,6 +141,7 @@ done" C-m kill_server() { local prefix + local tmux_response local server_id server_id="" @@ -281,14 +282,10 @@ update() { # Kill the server to ensure a smooth update kill_server -s "${server_id}" >/dev/null 2>&1 - local backup_dir - local backup_full_path local server_directory local server_name server_name="Server-${server_id}" server_directory="${BASE_DIR}/${server_name}" - backup_dir="${HOME}/Server-Backups/${server_name}" - backup_full_path="${backup_dir}/$(date +%s).tar.gz" backup -s "${server_id}" log "info" "Updating server $(important "${server_name}") located at $(important "${server_directory}")..." steamcmd +force_install_dir "${server_directory}" +login anonymous +app_update 294420 validate +quit @@ -351,7 +348,6 @@ backup() { log "info" "Backing up server $(important "${server_name}") to $(important "${backup_full_path}"), this may take a while" mkdir -p "${backup_dir}" - set -x tar cf - "${server_directory}" -P | pv -s "$(du -sb "${server_directory}" | awk '{print $1}')" | \ gzip > "${backup_full_path}" tar -czf "${server_directory}" "${backup_dir}"/ @@ -400,29 +396,26 @@ list_servers() { log "error" "An option must be passed for list, check list -h" && return 1 - case "${picked_option}" in - 1) - log "debug" "Listing running servers" - local tmux_sessions - tmux_sessions="$(tmux list-sessions)" >/dev/null 2>&1 - if [[ ! "${?}" -eq "0" ]]; then - important "No servers currently running." + if (( picked_option == 0 )); then + log "debug" "Listing running servers" + local tmux_sessions + tmux_sessions="$(tmux list-sessions)" >/dev/null 2>&1 + if [[ ! "${?}" -eq "0" ]]; then + important "No servers currently running." + fi + while read -r; do + if [[ "${REPLY}" = *"-Server-"* ]]; then + local running_server + running_server="$(echo "${REPLY}" | cut -d ":" -f1)" + important "${running_server}" fi - while read -r; do - if [[ "${REPLY}" = *"-Server-"* ]]; then - local running_server - running_server="$(echo "${REPLY}" | cut -d ":" -f1)" - important "${running_server}" - fi - done <<< "${tmux_sessions}" - ;; - 2) - log "debug" "Listing installed servers" - while read -r; do - important "${BASE_DIR}/${REPLY}" - done <<< "$(find "${BASE_DIR}" -name "startserver.sh" | cut -d "/" -f5)" - ;; - esac + done <<< "${tmux_sessions}" + elif (( picked_option == 1 )); then + log "debug" "Listing installed servers" + while read -r; do + important "${BASE_DIR}/${REPLY}" + done <<< "$(find "${BASE_DIR}" -name "startserver.sh" | cut -d "/" -f5)" + fi } usage() {