if the backup storage is local do not use webdav
This commit is contained in:
@@ -38,3 +38,36 @@ get_persistent_volume_keys() {
|
||||
fi
|
||||
done < <(get_volume_keys "$compose_file")
|
||||
}
|
||||
|
||||
# Returns 0 when a backup HTTP/WebDAV URL refers to this machine.
|
||||
is_local_backup_url() {
|
||||
local url=$1
|
||||
[[ -z "$url" ]] && return 1
|
||||
|
||||
local host="${url#*://}"
|
||||
host="${host%%/*}"
|
||||
host="${host%%:*}"
|
||||
[[ -z "$host" ]] && return 1
|
||||
|
||||
case "$host" in
|
||||
localhost|127.0.0.1|::1|0.0.0.0) return 0 ;;
|
||||
esac
|
||||
|
||||
local env_file
|
||||
env_file="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.env"
|
||||
if [[ -f "$env_file" ]]; then
|
||||
local domain ip
|
||||
domain=$(grep -E '^DOMAIN=' "$env_file" | head -n 1 | cut -d= -f2- | tr -d '"' | tr -d "'")
|
||||
ip=$(grep -E '^IP=' "$env_file" | head -n 1 | cut -d= -f2- | tr -d '"' | tr -d "'")
|
||||
[[ -n "$domain" && "$host" == "$domain" ]] && return 0
|
||||
[[ -n "$ip" && "$host" == "$ip" ]] && return 0
|
||||
fi
|
||||
|
||||
local local_fqdn local_short
|
||||
local_fqdn=$(hostname -f 2>/dev/null || true)
|
||||
local_short=$(hostname 2>/dev/null || true)
|
||||
[[ -n "$local_fqdn" && "$host" == "$local_fqdn" ]] && return 0
|
||||
[[ -n "$local_short" && "$host" == "$local_short" ]] && return 0
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user