|
@@ -43,9 +43,9 @@ fn_backup_init(){
|
|
|
info_distro.sh
|
|
info_distro.sh
|
|
|
fn_print_dots "Backup starting"
|
|
fn_print_dots "Backup starting"
|
|
|
fn_script_log_info "Backup starting"
|
|
fn_script_log_info "Backup starting"
|
|
|
- fn_print_ok "Backup starting"
|
|
|
|
|
|
|
+ fn_print_ok_nl "Backup starting"
|
|
|
if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then
|
|
if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then
|
|
|
- fn_print_info "There are no previous backups"
|
|
|
|
|
|
|
+ fn_print_info_nl "There are no previous backups"
|
|
|
else
|
|
else
|
|
|
if [ "${lastbackupdaysago}" == "0" ]; then
|
|
if [ "${lastbackupdaysago}" == "0" ]; then
|
|
|
daysago="less than 1 day ago"
|
|
daysago="less than 1 day ago"
|
|
@@ -54,7 +54,6 @@ fn_backup_init(){
|
|
|
else
|
|
else
|
|
|
daysago="${lastbackupdaysago} days ago"
|
|
daysago="${lastbackupdaysago} days ago"
|
|
|
fi
|
|
fi
|
|
|
- echo -en "\n"
|
|
|
|
|
echo -e "* Previous backup was created ${daysago}, total size ${lastbackupsize}"
|
|
echo -e "* Previous backup was created ${daysago}, total size ${lastbackupsize}"
|
|
|
fi
|
|
fi
|
|
|
}
|
|
}
|
|
@@ -74,8 +73,7 @@ fn_backup_stop_server(){
|
|
|
fn_script_log_warn "Although unlikely; creating a backup while ${selfname} is running might corrupt the backup"
|
|
fn_script_log_warn "Although unlikely; creating a backup while ${selfname} is running might corrupt the backup"
|
|
|
# Server is running and will be stopped if stoponbackup=on or unset.
|
|
# Server is running and will be stopped if stoponbackup=on or unset.
|
|
|
else
|
|
else
|
|
|
- fn_print_warn "${selfname} will be stopped during the backup"
|
|
|
|
|
- fn_script_log_warn "${selfname} will be stopped during the backup"
|
|
|
|
|
|
|
+ fn_stop_warning
|
|
|
serverstopped="yes"
|
|
serverstopped="yes"
|
|
|
exitbypass=1
|
|
exitbypass=1
|
|
|
command_stop.sh
|
|
command_stop.sh
|
|
@@ -135,7 +133,7 @@ fn_backup_compression(){
|
|
|
|
|
|
|
|
# Check that excludedir is a valid path.
|
|
# Check that excludedir is a valid path.
|
|
|
if [ ! -d "${excludedir}" ] ; then
|
|
if [ ! -d "${excludedir}" ] ; then
|
|
|
- fn_print_fail "Problem identifying the previous backup directory for exclusion."
|
|
|
|
|
|
|
+ fn_print_fail_nl "Problem identifying the previous backup directory for exclusion."
|
|
|
fn_script_log_fatal "Problem identifying the previous backup directory for exclusion"
|
|
fn_script_log_fatal "Problem identifying the previous backup directory for exclusion"
|
|
|
core_exit.sh
|
|
core_exit.sh
|
|
|
fi
|
|
fi
|
|
@@ -146,11 +144,11 @@ fn_backup_compression(){
|
|
|
fn_print_fail_eol
|
|
fn_print_fail_eol
|
|
|
fn_script_log_fatal "Backup in progress: FAIL"
|
|
fn_script_log_fatal "Backup in progress: FAIL"
|
|
|
echo -e "${tarcmd}" | tee -a "${lgsmlog}"
|
|
echo -e "${tarcmd}" | tee -a "${lgsmlog}"
|
|
|
- fn_print_fail "Starting backup"
|
|
|
|
|
|
|
+ fn_print_fail_nl "Starting backup"
|
|
|
fn_script_log_fatal "Starting backup"
|
|
fn_script_log_fatal "Starting backup"
|
|
|
else
|
|
else
|
|
|
fn_print_ok_eol
|
|
fn_print_ok_eol
|
|
|
- fn_print_ok "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')"
|
|
|
|
|
|
|
+ fn_print_ok_nl "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')"
|
|
|
fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')"
|
|
fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')"
|
|
|
fi
|
|
fi
|
|
|
# Remove lock file
|
|
# Remove lock file
|
|
@@ -171,7 +169,7 @@ fn_backup_prune(){
|
|
|
if [ "${backupquotadiff}" -gt "0" ]||[ "${backupsoudatedcount}" -gt "0" ]; then
|
|
if [ "${backupquotadiff}" -gt "0" ]||[ "${backupsoudatedcount}" -gt "0" ]; then
|
|
|
fn_print_dots "Pruning"
|
|
fn_print_dots "Pruning"
|
|
|
fn_script_log_info "Backup pruning activated"
|
|
fn_script_log_info "Backup pruning activated"
|
|
|
- fn_print_ok "Pruning"
|
|
|
|
|
|
|
+ fn_print_ok_nl "Pruning"
|
|
|
# If maxbackups greater or equal to backupsoutdatedcount, then it is over maxbackupdays.
|
|
# If maxbackups greater or equal to backupsoutdatedcount, then it is over maxbackupdays.
|
|
|
if [ "${backupquotadiff}" -ge "${backupsoudatedcount}" ]; then
|
|
if [ "${backupquotadiff}" -ge "${backupsoudatedcount}" ]; then
|
|
|
# Display how many backups will be cleared.
|
|
# Display how many backups will be cleared.
|
|
@@ -182,7 +180,7 @@ fn_backup_prune(){
|
|
|
fn_script_log_info "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
fn_script_log_info "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
|
# Clear backups over quota.
|
|
# Clear backups over quota.
|
|
|
find "${backupdir}"/ -type f -name "*.tar.gz" -printf '%T@ %p\n' | sort -rn | tail -${backupquotadiff} | cut -f2- -d" " | xargs rm
|
|
find "${backupdir}"/ -type f -name "*.tar.gz" -printf '%T@ %p\n' | sort -rn | tail -${backupquotadiff} | cut -f2- -d" " | xargs rm
|
|
|
- fn_print_ok "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
|
|
|
|
|
+ fn_print_ok_nl "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
|
fn_script_log_pass "Pruning: Cleared ${backupquotadiff} backup(s)"
|
|
fn_script_log_pass "Pruning: Cleared ${backupquotadiff} backup(s)"
|
|
|
# If maxbackupdays is used over maxbackups.
|
|
# If maxbackupdays is used over maxbackups.
|
|
|
elif [ "${backupquotadiff}" -lt "${backupsoudatedcount}" ]; then
|
|
elif [ "${backupquotadiff}" -lt "${backupsoudatedcount}" ]; then
|
|
@@ -194,7 +192,7 @@ fn_backup_prune(){
|
|
|
fn_script_log_info "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
fn_script_log_info "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
|
# Clear backups over quota
|
|
# Clear backups over quota
|
|
|
find "${backupdir}"/ -type f -mtime +"${maxbackupdays}" -exec rm -f {} \;
|
|
find "${backupdir}"/ -type f -mtime +"${maxbackupdays}" -exec rm -f {} \;
|
|
|
- fn_print_ok "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
|
|
|
|
|
+ fn_print_ok_nl "Pruning: Clearing ${backupquotadiff} backup(s)"
|
|
|
fn_script_log_pass "Pruning: Cleared ${backupquotadiff} backup(s)"
|
|
fn_script_log_pass "Pruning: Cleared ${backupquotadiff} backup(s)"
|
|
|
fi
|
|
fi
|
|
|
fi
|
|
fi
|
|
@@ -202,11 +200,9 @@ fn_backup_prune(){
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn_backup_relpath() {
|
|
fn_backup_relpath() {
|
|
|
- # Written by CedarLUG as a "realpath --relative-to" alternative in bash.
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # Written by CedarLUG as a "realpath --relative-to" alternative in bash.
|
|
|
# Populate an array of tokens initialized from the rootdir components.
|
|
# Populate an array of tokens initialized from the rootdir components.
|
|
|
- declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g"))
|
|
|
|
|
-
|
|
|
|
|
|
|
+ declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g"))
|
|
|
if [ ${#rdirtoks[@]} -eq 0 ]; then
|
|
if [ ${#rdirtoks[@]} -eq 0 ]; then
|
|
|
fn_print_fail_nl "Problem assessing rootdir during relative path assessment"
|
|
fn_print_fail_nl "Problem assessing rootdir during relative path assessment"
|
|
|
fn_script_log_fatal "Problem assessing rootdir during relative path assessment: ${rootdir}"
|
|
fn_script_log_fatal "Problem assessing rootdir during relative path assessment: ${rootdir}"
|
|
@@ -214,7 +210,7 @@ fn_backup_relpath() {
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
# Populate an array of tokens initialized from the backupdir components.
|
|
# Populate an array of tokens initialized from the backupdir components.
|
|
|
- declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g"))
|
|
|
|
|
|
|
+ declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g"))
|
|
|
if [ ${#bdirtoks[@]} -eq 0 ]; then
|
|
if [ ${#bdirtoks[@]} -eq 0 ]; then
|
|
|
fn_print_fail_nl "Problem assessing backupdir during relative path assessment"
|
|
fn_print_fail_nl "Problem assessing backupdir during relative path assessment"
|
|
|
fn_script_log_fatal "Problem assessing backupdir during relative path assessment: ${rootdir}"
|
|
fn_script_log_fatal "Problem assessing backupdir during relative path assessment: ${rootdir}"
|
|
@@ -223,31 +219,46 @@ fn_backup_relpath() {
|
|
|
|
|
|
|
|
# Compare the leading entries of each array. These common elements will be clipped off.
|
|
# Compare the leading entries of each array. These common elements will be clipped off.
|
|
|
# for the relative path output.
|
|
# for the relative path output.
|
|
|
- for ((base=0; base<${#rdirtoks[@]}; base++))
|
|
|
|
|
- do
|
|
|
|
|
- [[ "${rdirtoks[$base]}" != "${bdirtoks[$base]}" ]] && break
|
|
|
|
|
- done
|
|
|
|
|
|
|
+ for ((base=0; base<${#rdirtoks[@]}; base++))
|
|
|
|
|
+ do
|
|
|
|
|
+ [[ "${rdirtoks[$base]}" != "${bdirtoks[$base]}" ]] && break
|
|
|
|
|
+ done
|
|
|
|
|
|
|
|
# Next, climb out of the remaining rootdir location with updir references.
|
|
# Next, climb out of the remaining rootdir location with updir references.
|
|
|
- for ((x=base;x<${#rdirtoks[@]};x++))
|
|
|
|
|
- do
|
|
|
|
|
- echo -n "../"
|
|
|
|
|
- done
|
|
|
|
|
|
|
+ for ((x=base;x<${#rdirtoks[@]};x++))
|
|
|
|
|
+ do
|
|
|
|
|
+ echo -n "../"
|
|
|
|
|
+ done
|
|
|
|
|
|
|
|
# Climb down the remaining components of the backupdir location.
|
|
# Climb down the remaining components of the backupdir location.
|
|
|
- for ((x=base;x<$(( ${#bdirtoks[@]} - 1 ));x++))
|
|
|
|
|
- do
|
|
|
|
|
- echo -n "${bdirtoks[$x]}/"
|
|
|
|
|
- done
|
|
|
|
|
|
|
+ for ((x=base;x<$(( ${#bdirtoks[@]} - 1 ));x++))
|
|
|
|
|
+ do
|
|
|
|
|
+ echo -n "${bdirtoks[$x]}/"
|
|
|
|
|
+ done
|
|
|
|
|
|
|
|
# In the event there were no directories left in the backupdir above to
|
|
# In the event there were no directories left in the backupdir above to
|
|
|
# traverse down, just add a newline. Otherwise at this point, there is
|
|
# traverse down, just add a newline. Otherwise at this point, there is
|
|
|
# one remaining directory component in the backupdir to navigate.
|
|
# one remaining directory component in the backupdir to navigate.
|
|
|
- if (( "$base" < "${#bdirtoks[@]}" )) ; then
|
|
|
|
|
- echo -e "${bdirtoks[ $(( ${#bdirtoks[@]} - 1)) ]}"
|
|
|
|
|
- else
|
|
|
|
|
- echo
|
|
|
|
|
|
|
+ if (( "$base" < "${#bdirtoks[@]}" )) ; then
|
|
|
|
|
+ echo -e "${bdirtoks[ $(( ${#bdirtoks[@]} - 1)) ]}"
|
|
|
|
|
+ else
|
|
|
|
|
+ echo
|
|
|
|
|
+ fi
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+fn_stop_warning(){
|
|
|
|
|
+ fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup"
|
|
|
|
|
+ fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup"
|
|
|
|
|
+ totalseconds=3
|
|
|
|
|
+ for seconds in {3..1}; do
|
|
|
|
|
+ fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup: ${totalseconds}"
|
|
|
|
|
+ totalseconds=$((totalseconds - 1))
|
|
|
|
|
+ sleep 1
|
|
|
|
|
+ if [ "${seconds}" == "0" ]; then
|
|
|
|
|
+ break
|
|
|
fi
|
|
fi
|
|
|
|
|
+ done
|
|
|
|
|
+ fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during backup"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# Restart the server if it was stopped for the backup.
|
|
# Restart the server if it was stopped for the backup.
|