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/borg.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/borg.sh')
-rw-r--r-- | backends/borg.sh | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/backends/borg.sh b/backends/borg.sh index b0351a0..ec39bc8 100644 --- a/backends/borg.sh +++ b/backends/borg.sh @@ -1,7 +1,7 @@ function borg_init() { local encryption if [ -z "$BACKUP_PASSCOMMAND" ] ; then - echo "borg: no password given, repository is not protected" + log_info "borg: no password given, repository is not protected" encryption="none" else encryption="repokey-blake2" @@ -10,9 +10,10 @@ function borg_init() { export BORG_PASSCOMMAND="$BACKUP_PASSCOMMAND" for backup_dir in ${BACKUP_DIRS[*]} do + log_debug "Initializing repo at $backup_dir " # borg will check if repo exists borg init --encryption="$encryption" "$backup_dir" - done + done } function borg_create_backup() { @@ -22,9 +23,9 @@ function borg_create_backup() { do export BORG_REPO="$backup_dir" - trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM + trap 'echo [WARNING] $( date ) Backup interrupted >&2; exit 2' INT TERM - echo "borg: backing up to \"$backup_dir\"" + log_info "borg: backing up to \"$backup_dir\"" borg create \ "${backup_dir}::${BACKUP_NAME}_$(date +'%F_%H-%M-%S')" \ @@ -35,7 +36,7 @@ function borg_create_backup() { local backup_exit=$? - echo_debug "borg: pruning repository at \"$backup_dir\"" + log_debug "borg: pruning repository at \"$backup_dir\"" borg prune \ --prefix '{hostname}-' \ @@ -53,11 +54,11 @@ function borg_create_backup() { retcode=$(( global_exit > retcode ? global_exit : retcode )) if [ ${global_exit} -eq 0 ]; then - echo_debug "borg: backup and prune finished successfully" + log_debug "borg: backup and prune finished successfully" elif [ ${global_exit} -eq 1 ]; then - echo "borg: backup and/or prune finished with warnings" + log_info "borg: backup and/or prune finished with warnings" else - echo "borg: backup and/or prune finished with errors" + log_error "borg: backup and/or prune finished with errors" fi #exit ${global_exit} done @@ -65,20 +66,11 @@ function borg_create_backup() { } # server_restore relies on output format of this function -function borg_ls_dir() { +function borg_ls() { export BORG_PASSCOMMAND="$BACKUP_PASSCOMMAND" borg list "$1" | cut -d' ' -f1 | sort -r } -function borg_ls_all() { - export BORG_PASSCOMMAND="$BACKUP_PASSCOMMAND" - for backup_dir in ${BACKUP_DIRS[*]} - do - echo "borg: backups in \"$backup_dir\":" - borg list "$backup_dir" | cut -d' ' -f1 - done -} - function borg_restore() { export BORG_PASSCOMMAND="$BACKUP_PASSCOMMAND" local remote="$1" |