Added backup function

This commit is contained in:
Price Hiller 2021-12-24 23:07:00 -06:00
parent 195e28421e
commit 2eea6f5521

View File

@ -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,8 +396,7 @@ list_servers() {
log "error" "An option must be passed for list, check list -h" &&
return 1
case "${picked_option}" in
1)
if (( picked_option == 0 )); then
log "debug" "Listing running servers"
local tmux_sessions
tmux_sessions="$(tmux list-sessions)" >/dev/null 2>&1
@ -415,14 +410,12 @@ list_servers() {
important "${running_server}"
fi
done <<< "${tmux_sessions}"
;;
2)
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)"
;;
esac
fi
}
usage() {