From: Bastian Dehn Date: Wed, 5 Aug 2026 14:57:28 +0000 (+0200) Subject: add info lines X-Git-Tag: v1.0.6^2~1^2~55 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=cfb712b1fdb08471c557ae7c59f4f3fe37866912;p=simple-backup.git add info lines --- diff --git a/src/backup b/src/backup index 7433745..a97063a 100755 --- a/src/backup +++ b/src/backup @@ -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 $? diff --git a/src/config-example.yaml b/src/config-example.yaml index e1c2ebc..4d340d3 100644 --- a/src/config-example.yaml +++ b/src/config-example.yaml @@ -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 diff --git a/tests/backup_tests.bats b/tests/backup_tests.bats index c220d45..0b614f3 100755 --- a/tests/backup_tests.bats +++ b/tests/backup_tests.bats @@ -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