From b6e3f1bb2b987d83b9d134c7a01065c210a6f3ca Mon Sep 17 00:00:00 2001 From: "kebler.net" Date: Sun, 29 Aug 2021 09:30:12 -0700 Subject: [PATCH] fix: server string --- all/dev/backup/dbackup | 12 +++++++++--- all/dev/backup/src/root_command.sh | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/all/dev/backup/dbackup b/all/dev/backup/dbackup index 11931f5..edd5141 100755 --- a/all/dev/backup/dbackup +++ b/all/dev/backup/dbackup @@ -23,13 +23,16 @@ root_command() { eval $(parse_yaml $settings "s_") echo $s_source echo $s_target + echo $s_host fi if [[ $s_server_host ]]; then - s_server="rest:http$([[ $s_server_secure ]] && echo "s")://${s_server_host}$([[ $s_server_port ]] && echo :${s_server_port})" + s_server="http$([[ $s_server_secure ]] && echo "s")://${s_server_host}$([[ $s_server_port ]] && echo :${s_server_port} || echo "")" fi + + local password=${args[--password]:-$BACKUP_PASSWORD} password=${password:-$s_password} [[ ! $password ]] && echo restic requires a backup repository password, exiting && return 2 @@ -38,6 +41,9 @@ root_command() { local server=${args[--server]:-$BACKUP_SERVER} server=${server:-$s_server} + echo server $s_server + echo server $server + local backup_dir=${args[--backup_dir]:-$BACKUP_DIR} backup_dir=${backup_dir:-$s_backup_dir} backup_dir=${backup_dir:-"/backup"} @@ -53,9 +59,9 @@ root_command() { if [[ $(isAbsPath $target) ]]; then echo absolute target directory else - target="/${HOSTNAME}/${target}" + target="/${s_host:-$HOSTNAME}/${target}" if [[ $server ]]; then - target="${server}${target}" + target="rest:${server}${target}" else target=${backup_dir}${target} fi diff --git a/all/dev/backup/src/root_command.sh b/all/dev/backup/src/root_command.sh index b0b1ded..7590110 100644 --- a/all/dev/backup/src/root_command.sh +++ b/all/dev/backup/src/root_command.sh @@ -16,13 +16,16 @@ if [[ -f $settings ]]; then eval $(parse_yaml $settings "s_") echo $s_source echo $s_target + echo $s_host fi if [[ $s_server_host ]]; then - s_server="rest:http$([[ $s_server_secure ]] && echo "s")://${s_server_host}$([[ $s_server_port ]] && echo :${s_server_port})" + s_server="http$([[ $s_server_secure ]] && echo "s")://${s_server_host}$([[ $s_server_port ]] && echo :${s_server_port} || echo "")" fi + + local password=${args[--password]:-$BACKUP_PASSWORD} password=${password:-$s_password} [[ ! $password ]] && echo restic requires a backup repository password, exiting && return 2 @@ -31,6 +34,9 @@ password="RESTIC_PASSWORD=${password}" local server=${args[--server]:-$BACKUP_SERVER} server=${server:-$s_server} +echo server $s_server +echo server $server + local backup_dir=${args[--backup_dir]:-$BACKUP_DIR} backup_dir=${backup_dir:-$s_backup_dir} backup_dir=${backup_dir:-"/backup"} @@ -46,9 +52,9 @@ fi if [[ $(isAbsPath $target) ]]; then echo absolute target directory else - target="/${HOSTNAME}/${target}" + target="/${s_host:-$HOSTNAME}/${target}" if [[ $server ]]; then - target="${server}${target}" + target="rest:${server}${target}" else target=${backup_dir}${target} fi