local last_backup_dir_path="$3"
local hardlinkopt=
local remote_user=$(cat config.yaml \
- | yq -r ".machines.\"$machine\".remote_user")
- local host=$(cat config.yaml | yq -r ".machines.\"$machine\".host")
- local port=$(cat config.yaml | yq -r ".machines.\"$machine\".port")
- local pathes=$(cat config.yaml | yq -r ".machines.\"$machine\".pathes[]")
+ | yq --raw-output ".machines.\"$machine\".remote_user")
+ [ -n "$remote_user" ] && [ $remote_user != "null" ] \
+ || errlog "config.yaml missing remote_user for $machine" \
+ || return $?
+ local host=$(cat config.yaml \
+ | yq --raw-output ".machines.\"$machine\".host")
+ [ -n "$host" ] && [ "$host" != "null" ] \
+ || errlog "config.yaml missing host for $machine" \
+ || return $?
+ local port=$(cat config.yaml \
+ | yq --raw-output ".machines.\"$machine\".port")
+ [ -n "$port" ] && [ "$port" != "null" ] \
+ || errlog "config.yaml missing port for $machine" \
+ || return $?
+ local pathes=$(cat config.yaml \
+ | yq --raw-output ".machines.\"$machine\".pathes[]")
+ [ -n "$pathes" ] \
+ || errlog "config.yaml missing pathes for $machine" \
+ || return $?
local YELLOW="\e[0;33m"
local LIGHTPURPLE="\e[1;35m"
local backup_path="$1"
local last_backup_dir_path="$2"
local hardlinkopt=
- local machines=$(cat config.yaml | yq -r '.machines | keys[]')
+ local machines=$(cat config.yaml | yq --raw-output '.machines | keys[]')
+ [ -n "$machines" ] \
+ || errlog "config.yaml no machines" \
+ || return $?
for machine in $machines; do
echo "ℹ️ INFO: create direcotry $backup_path/$machine"
|| errlog "file config.yaml not found" \
|| return $?
- backup_path=$(cat config.yaml | yq -r '.backup_path')
- backup_name=$(cat config.yaml | yq -r '.backup_name')
- backup_count=$(cat config.yaml | yq -r '.backup_count')
+ backup_path=$(cat config.yaml | yq --raw-output '.backup_path')
+ backup_name=$(cat config.yaml | yq --raw-output '.backup_name')
+ backup_count=$(cat config.yaml | yq --raw-output '.backup_count')
[ -n "$backup_path" ] && [ "$backup_path" != "null" ] \
- || errlog "missing backup_path in config.yaml" \
+ || errlog "config.yaml missing backup_path" \
|| return $?
[ -d "$backup_path" ] \
|| errlog "directory $backup_path not exists" \
|| return $?
echo "ℹ️ INFO: backup path $backup_path"
[ -n "$backup_name" ] && [ "$backup_name" != "null" ] \
- || errlog "missing backup_name in config.yaml" \
+ || errlog "config.yaml missing backup_name" \
|| return $?
echo "ℹ️ INFO: backup name $backup_name"
[ -n "$backup_count" ] && [ "$backup_count" != "null" ] \
- || errlog "missing backup_count in config.yaml" \
+ || errlog "config.yaml missing backup_count" \
|| return $?
echo "ℹ️ INFO: backup count $backup_count"
-
local backup_dir=$(get_backup_dir \
"$backup_path" \
"$backup_name")
"$backup_name")
echo "ℹ️ INFO: last backup dir path $last_backup_dir_path"
- backup_remotes "$backup_full_path" "$last_backup_dir_path" || return $?
- make_history "$backup_path" || return $?
- check_backup_date || return $?
- cleanup_backups "$backup_path" "$backup_name" $backup_count \
+ backup_remotes \
+ "$backup_full_path" \
+ "$last_backup_dir_path" \
+ || return $?
+ make_history \
+ "$backup_path" \
+ || return $?
+ check_backup_date \
+ || return $?
+ cleanup_backups \
+ "$backup_path" \
+ "$backup_name" \
+ $backup_count \
|| return $?
echo "✅ SUCCESS: backup"