]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add only localhost
authorBastian Dehn <hhaalo@arcor.de>
Thu, 6 Aug 2026 16:59:30 +0000 (18:59 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 6 Aug 2026 16:59:30 +0000 (18:59 +0200)
src/backup
src/config-example.yaml
tests/backup_tests.bats

index 501f7fcc2c3f353aaef99429fa074e40dade4ec2..2528484410185535a77d5f617195b1db986e5f9d 100755 (executable)
@@ -172,6 +172,7 @@ path_backup()
        done
        rsyncargs+=("--rsh=\"ssh -p $port\"")
        local hostpath="$remote_user@$host:$path"
+       [ "$host" == "localhost" ] && hostpath="$path"
        rsyncargs+=("$hostpath")
        rsyncargs+=("$full_backup_path")
 
@@ -218,7 +219,7 @@ backup_machines()
        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=
index 030d19735f05db1ce2ab12248e3f97c1a42feb3d..70c8bbadeb8704e8e9a77006fe769bde0de57a79 100644 (file)
@@ -20,6 +20,12 @@ machines:
     port: 22
     pathes:
       - /home/other
+  onlylocal:
+    remote_user: user
+    host: localhost
+    port: 22
+    pathes:
+      - /home/local
 
 # the next block need backupmount for mount luks devices
 backup_volume: luks-crypt-volume
index eb5903d0ddceb9d31823d706386793f30b744d47..023ff9d44676b9bd41a1f854d89e2738bee3f664 100755 (executable)
@@ -295,7 +295,8 @@ teardown() {
        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" ]
@@ -325,7 +326,11 @@ teardown() {
        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" {
@@ -535,4 +540,24 @@ teardown() {
        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