]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add info lines
authorBastian Dehn <hhaalo@arcor.de>
Wed, 5 Aug 2026 14:57:28 +0000 (16:57 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 5 Aug 2026 14:57:28 +0000 (16:57 +0200)
src/backup
src/config-example.yaml
tests/backup_tests.bats

index 7433745d06fca61955c20c3343a9f814d26059ed..a97063aa61854757cb93d533d5a79003516485fa 100755 (executable)
@@ -122,7 +122,30 @@ create_backup_dir()
        mkdir --parents "$backup_full_path"
 }
 
-backup_remotes()
+print_line()
+{
+       printf "#%.0s" {1..80}
+       printf "\n"
+}
+
+machine_backup_pathes()
+{
+       local config="$1"
+       local machine="$2"
+       local pathes=()
+       mapfile -t pathes < <(echo "$config" \
+               | jq --raw-output ".machines.$machine.pathes[]")
+
+       local path=
+       for path in "${pathes[@]}"; do
+               print_line
+               printf "ℹ️ INFO: machine ${LIGHTPURPLE}%s${RESET}; " "$machine"
+               printf "path ${YELLOW}%s${RESET}\n\n" "$path"
+               print_line
+       done
+}
+
+backup_machines()
 {
        local config="$1"
        local backup_dir="$2"
@@ -139,6 +162,9 @@ backup_remotes()
                full_backup_path="$backup_path/$backup_dir/$machine"
                echo "ℹ️ INFO: create directory $full_backup_path"
                mkdir --parents "$full_backup_path"
+               machine_backup_pathes "$config" \
+                       "$machine" \
+                       || return $?
        done
 }
 
@@ -170,7 +196,7 @@ main()
        backup_dir=$(get_backup_dir "$config")
        echo "ℹ️ INFO: backup folder $backup_dir"
        create_backup_dir "$config" "$backup_dir"
-       backup_remotes "$config" \
+       backup_machines "$config" \
                "$backup_dir" \
                "$last_backup_dir_path" \
                || return $?
index e1c2ebcc99ce7b231ac76f7f661a3d2de8d47882..4d340d307b41d709933441d0814ed6b36e216651 100644 (file)
@@ -23,8 +23,7 @@ machines:
       - /home/user/.cache
       - /home/user/.local
     pathes:
-      - /etc
-      - /home/user
+      - /home/other
 
 # the next block need backupmount for mount luks devices
 backup_volume: luks-crypt-volume
index c220d4582f7365c5c79aa056d3aa53607274c3b6..0b614f3cde78763852e5f8589ce486849fa0cd54 100755 (executable)
@@ -168,7 +168,7 @@ teardown() {
        create_backup_dir() {
                :
        }
-       backup_remotes() {
+       backup_machines() {
                :
        }
 
@@ -189,7 +189,7 @@ teardown() {
        find() {
                echo "build/2000-01-01_01_backup"
        }
-       backup_remotes() {
+       backup_machines() {
                :
        }
 
@@ -208,7 +208,7 @@ teardown() {
        create_backup_dir() {
                :
        }
-       backup_remotes() {
+       backup_machines() {
                :
        }
 
@@ -228,7 +228,7 @@ teardown() {
        create_backup_dir() {
                :
        }
-       backup_remotes() {
+       backup_machines() {
                :
        }
 
@@ -246,9 +246,10 @@ teardown() {
 }
 
 @test "create backup folder" {
-       backup_remotes() {
+       backup_machines() {
                :
        }
+
        run main
 
        assert_success
@@ -263,9 +264,12 @@ teardown() {
 }
 
 @test "backup remotes" {
+       machine_backup_pathes() {
+               :
+       }
+
        run main
 
-       assert_success
        assert_success
        assert_line --index 0 "⭐ START: backup"
        assert_line --index 1 "ℹ️ INFO: backup path build"
@@ -279,4 +283,28 @@ teardown() {
        [ -d "build/2000-01-01_01_backup" ]
        [ -d "build/2000-01-01_01_backup/testpc1" ]
        [ -d "build/2000-01-01_01_backup/testpc2" ]
+}
+
+@test "backup remote pathes" {
+       run main
+
+       assert_success
+       assert_line --index 0 "⭐ START: backup"
+       assert_line --index 1 "ℹ️ INFO: backup path build"
+       assert_line --index 2 "ℹ️ INFO: backup name backup"
+       assert_line --index 3 "ℹ️ INFO: backup count 15"
+       assert_line --index 4 "ℹ️ INFO: backup folder 2000-01-01_01_backup"
+       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 "################################################################################"
+       assert_line --index 8 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc1${RESET}; path ${YELLOW}/etc${RESET}"
+       assert_line --index 9 "################################################################################"
+       assert_line --index 10 "################################################################################"
+       assert_line --index 11 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc1${RESET}; path ${YELLOW}/home/user${RESET}"
+       assert_line --index 12 "################################################################################"
+       assert_line --index 13 "ℹ️ INFO: create directory 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"
 }
\ No newline at end of file