Added backup function
This commit is contained in:
parent
195e28421e
commit
2eea6f5521
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user