done
rsyncargs+=("--rsh=\"ssh -p $port\"")
local hostpath="$remote_user@$host:$path"
+ [ "$host" == "localhost" ] && hostpath="$path"
rsyncargs+=("$hostpath")
rsyncargs+=("$full_backup_path")
local machines=()
backup_path=$(echo "$config" | jq --raw-output '.backup_path')
mapfile -t machines < <(echo "$config" \
- | jq --raw-output '.machines | keys[]')
+ | jq --raw-output '.machines | keys_unsorted[]')
local full_backup_path=
local machine=
assert_line --index 5 "ℹ️ INFO: create folder build/2000-01-01_01_backup"
assert_line --index 6 "ℹ️ INFO: create directory build/2000-01-01_01_backup/testpc1"
assert_line --index 7 "ℹ️ INFO: create directory build/2000-01-01_01_backup/testpc2"
- assert_line --index 8 "✅ SUCCESS: backup"
+ assert_line --index 8 "ℹ️ INFO: create directory build/2000-01-01_01_backup/onlylocal"
+ assert_line --index 9 "✅ SUCCESS: backup"
[ -d "build/2000-01-01_01_backup" ]
[ -d "build/2000-01-01_01_backup/testpc1" ]
[ -d "build/2000-01-01_01_backup/testpc2" ]
assert_line --index 14 "################################################################################"
assert_line --index 15 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc2${RESET}; path ${YELLOW}/home/other${RESET}"
assert_line --index 16 "################################################################################"
- assert_line --index 17 "✅ SUCCESS: backup"
+ assert_line --index 17 "ℹ️ INFO: create directory build/2000-01-01_01_backup/onlylocal"
+ assert_line --index 18 "################################################################################"
+ assert_line --index 19 "ℹ️ INFO: machine ${LIGHTPURPLE}onlylocal${RESET}; path ${YELLOW}/home/local${RESET}"
+ assert_line --index 20 "################################################################################"
+ assert_line --index 21 "✅ SUCCESS: backup"
}
@test "failure backup machine pathes is null" {
assert_equal "$(awk 'NR==9 {print; exit}' "$RSYNC_LOG")" "--rsh=\"ssh -p 22\""
assert_equal "$(awk 'NR==10 {print; exit}' "$RSYNC_LOG")" "backupuser@www.example.com:/home/other"
assert_equal "$(awk 'NR==11 {print; exit}' "$RSYNC_LOG")" "build/2000-01-01_01_backup/testpc2"
+}
+
+@test "success backup machine path rsync localhost" {
+ 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")" "10"
+ 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")" "/home/local"
+ assert_equal "$(awk 'NR==11 {print; exit}' "$RSYNC_LOG")" "build/2000-01-01_01_backup/onlylocal"
}
\ No newline at end of file