]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add rsync parameters
authorBastian Dehn <hhaalo@arcor.de>
Wed, 5 Aug 2026 19:41:59 +0000 (21:41 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 5 Aug 2026 19:41:59 +0000 (21:41 +0200)
src/backup
tests/backup_tests.bats

index 4aa335c79fc5718fda3c6ad8aaedbae22b46e563..1aab725fe1b32ef3e2e5607de606a21e4bf52897 100755 (executable)
@@ -158,7 +158,24 @@ path_backup()
                2> /dev/null)
        [ "${#excludes[@]}" -eq "0" ] \
                || echo "ℹ️ INFO: machine $machine; excludes ${excludes[*]}"
-       # TODO: config read - rsync implementation
+
+       rsyncargs=("--archive"
+               "--verbose"
+               "--sparse"
+               "--acls"
+               "--hard-links"
+               "--relative"
+               "--human-readable")
+       local exclude=
+       for exclude in "${excludes[@]}"; do
+               rsyncargs+=("--exclude=\"$exclude\"")
+       done
+       rsyncargs+=("--rsh=ssh -p $port")
+       local hostpath="$remote_user@$host:$path"
+       rsyncargs+=("$hostpath")
+       rsyncargs+=("$backup_path/$machine")
+
+       rsync "${rsyncargs[@]}"
 }
 
 machine_backup_pathes()
index 4385953a1024a28d066e62ca9717244e53bf3fba..650100b1f573acc65e29ea24609fd72acf1e2f18 100755 (executable)
@@ -10,6 +10,9 @@ setup() {
        date() {
                echo "2000-01-01"
        }
+       rsync() {
+               :
+       }
 }
 
 teardown() {
@@ -477,4 +480,26 @@ teardown() {
        assert_line --index 8 "ℹ️ INFO: machine ${LIGHTPURPLE}testpc1${RESET}; path ${YELLOW}/home/user${RESET}"
        assert_line --index 9 "################################################################################"
        assert_line --index 10 "✅ SUCCESS: backup"
+}
+
+@test "success backup machine path rsync parameters" {
+       rsync() {
+               [ "$1" == "--archive" ]; shift
+               [ "$1" == "--verbose" ]; shift
+               [ "$1" == "--sparse" ]; shift
+               [ "$1" == "--acls" ]; shift
+               [ "$1" == "--hard-links" ]; shift
+               [ "$1" == "--relative" ]; shift
+               [ "$1" == "--human-readable" ]; shift
+               [ "$1" == "--exclude=\"/home/user/.cache\"" ]; shift
+               [ "$1" == "--exclude=\"/home/user/.local\"" ]; shift
+               [ "$1" == "--rsh=\"ssh -p 22\"" ]; shift
+               [ "$1" == "backupuser@www.example.com:/etc" ]; shift
+               [ "$1" == "build/2000-01-01_01_backup/testpc1" ]; shift
+       }
+       run main
+
+       assert_success
+       assert_line --index 0 "⭐ START: backup"
+       assert_line --partial "✅ SUCCESS: backup"
 }
\ No newline at end of file