local machine="$2"
local path="$3"
local full_backup_path="$4"
+ local last_backup_dir_path="$5"
local remote_user=
local host=
rsyncargs+=("--exclude=$exclude")
done
rsyncargs+=("--rsh=\"ssh -p $port\"")
+ [ -n "$last_backup_dir_path" ] \
+ && rsyncargs+=("--link-dest=$last_backup_dir_path/$machine")
+
local hostpath="$remote_user@$host:$path"
[ "$host" == "localhost" ] && hostpath="$path"
rsyncargs+=("$hostpath")
local config="$1"
local machine="$2"
local full_backup_path="$3"
+ local last_backup_dir_path="$4"
local pathes=()
mapfile -t pathes < <(echo "$config" \
| jq --raw-output ".machines.$machine.pathes[]" \
"$machine" \
"$path" \
"$full_backup_path" \
+ "$last_backup_dir_path" \
|| return $?
print_line
done
machine_backup_pathes "$config" \
"$machine" \
"$full_backup_path" \
+ "$last_backup_dir_path" \
|| return $?
done
}
assert_equal "$(awk 'NR==11 {print; exit}' "$RSYNC_LOG")" "build/2000-01-01_01_backup/onlylocal"
}
+@test "success backup machine path rsync localhost with hard links" {
+ mkdir --parents "build/1999-12-31_01_backup"
+
+ RSYNC_LOG_RUNS="4"
+ run main
+
+ assert_success
+ assert_line --index 0 "⭐ START: backup"
+ assert_line --partial "✅ SUCCESS: backup"
+ assert_equal "$(awk 'NR==1 {print; exit}' "$RSYNC_LOG")" "11"
+ assert_equal "$(awk 'NR==2 {print; exit}' "$RSYNC_LOG")" "--archive"
+ assert_equal "$(awk 'NR==3 {print; exit}' "$RSYNC_LOG")" "--verbose"
+ assert_equal "$(awk 'NR==4 {print; exit}' "$RSYNC_LOG")" "--sparse"
+ assert_equal "$(awk 'NR==5 {print; exit}' "$RSYNC_LOG")" "--acls"
+ assert_equal "$(awk 'NR==6 {print; exit}' "$RSYNC_LOG")" "--hard-links"
+ assert_equal "$(awk 'NR==7 {print; exit}' "$RSYNC_LOG")" "--relative"
+ assert_equal "$(awk 'NR==8 {print; exit}' "$RSYNC_LOG")" "--human-readable"
+ assert_equal "$(awk 'NR==9 {print; exit}' "$RSYNC_LOG")" "--rsh=\"ssh -p 22\""
+ assert_equal "$(awk 'NR==10 {print; exit}' "$RSYNC_LOG")" "--link-dest=build/1999-12-31_01_backup/onlylocal"
+ assert_equal "$(awk 'NR==11 {print; exit}' "$RSYNC_LOG")" "/home/local"
+ assert_equal "$(awk 'NR==12 {print; exit}' "$RSYNC_LOG")" "build/2000-01-01_01_backup/onlylocal"
+}
+
@test "failure backup machine path rsync failed" {
rsync() {
return 1