diff options
author | TheMightyV <themightyv@protonmail.com> | 2022-01-05 22:04:10 +0100 |
---|---|---|
committer | TheMightyV <themightyv@protonmail.com> | 2022-01-05 22:04:10 +0100 |
commit | ae5db1b37ae8554dff72b0da42ccbbbbc64baf71 (patch) | |
tree | 453b212c75d89f796628b46f1103807a3da9fb8b /backends/bup.sh | |
parent | 1ba766d277fc35435ca80b9fcfa28c57468f7bce (diff) | |
download | minecraft-server-tools-ae5db1b37ae8554dff72b0da42ccbbbbc64baf71.tar.gz |
split echos to debug/info/error levels
unified ls_all backend functions
unified backend function calls
ls_dir -> ls in backends
fixed accidental echo -> log_info replacement
Diffstat (limited to 'backends/bup.sh')
-rw-r--r-- | backends/bup.sh | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/backends/bup.sh b/backends/bup.sh index d1250de..6aa92b6 100644 --- a/backends/bup.sh +++ b/backends/bup.sh @@ -15,14 +15,14 @@ function bup_init() { bup -d "$(bup_local)" index "$WORLD_NAME" local status=$? if [ $status -ne 0 ]; then - echo_debug "bup: no local repo found, creating..." + log_debug "bup: no local repo found, creating..." bup -d "$(bup_local)" init -r "$(bup_local)" - echo_debug "bup: created local repo at $(bup_local)" + log_debug "bup: created local repo at $(bup_local)" fi } function bup_create_backup() { - echo_debug "bup: backup started" + log_debug "bup: backup started" bup -d "$(bup_local)" index "$WORLD_NAME" @@ -31,20 +31,20 @@ function bup_create_backup() { local retcode=1 for backup_dir in ${BACKUP_DIRS[*]} do - echo "bup: backing up to \"$backup_dir\"" + log_info "bup: backing up to \"$backup_dir\"" # try to save to remote bup -d "$(bup_local)" save -r "$backup_dir" -n "$BACKUP_NAME" "$WORLD_NAME" local status=$? # if failed - reinit remote and try again if [ $status -ne 0 ]; then - echo_debug "bup: failed backing up to \"$backup_dir\", reinitializing remote..." + log_debug "bup: failed backing up to \"$backup_dir\", reinitializing remote..." bup -d "$(bup_local)" init -r "$backup_dir" status=$? - if [ $status -ne 0 ]; then - echo_debug "bup: created remote at \"$backup_dir\"" + if [ $status -eq 0 ]; then + log_debug "bup: created remote at \"$backup_dir\"" bup -d "$(bup_local)" save -r "$backup_dir" -n "$BACKUP_NAME" "$WORLD_NAME" else - echo "bup: failed to make remote at \"$backup_dir\", moving on" + log_error "bup: failed to make remote at \"$backup_dir\", moving on" fi else if [ ! "$backup_dir" = "$(bup_local)" ]; then @@ -53,24 +53,16 @@ function bup_create_backup() { fi done - echo "bup: backup finished" + log_debug "bup: backup finished" return $retcode } # server_restore relies on output format of this function -function bup_ls_dir() { +function bup_ls() { local backup_dir="$1" bup -d "$(bup_local)" ls -r "$backup_dir" "$BACKUP_NAME" | sort -r } -function bup_ls_all() { - for backup_dir in ${BACKUP_DIRS[*]} - do - echo "bup: backups in \"$backup_dir\":" - bup -d "$(bup_local)" ls -r "$backup_dir" --human-readable -l "$BACKUP_NAME" - done -} - function bup_restore() { local remote="$1" local snapshot="$2" |