]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
change: all logins with remoteport
authorBastian Dehn <hhaalo@arcor.de>
Wed, 7 Nov 2018 19:11:20 +0000 (20:11 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 7 Nov 2018 19:27:18 +0000 (20:27 +0100)
backup

diff --git a/backup b/backup
index cad62debf9a3789c6a19de8da9c78c9b3f6e24f3..c72841378efde58862e1f5fe1b7c9eade852459d 100755 (executable)
--- a/backup
+++ b/backup
@@ -109,26 +109,30 @@ BackupTypOfVMDisc()
        if [ "$DiskType" == "file" ]; then
                rsync --archive --verbose --sparse --acls --hard-links \
                        --relative --progress --human-readable \
-                       --log-file=$logFile $hardlinkopt $remoteLogin:$Disk \
+                       --log-file=$logFile $hardlinkopt \
+                       -rsh "ssh -p $remoteport" $remoteLogin:$Disk \
                        $backRemotePCPath
        elif [ "$DiskType" == "block" ]; then
                local readonly DiskName=$(echo $Disk | sed 's/^\///' \
                        | sed 's/\//-/g')
-               local readonly DiskSize=$(ssh $remoteLogin fdisk --list $Disk \
+               local readonly DiskSize=$(ssh -p  $remoteport $remoteLogin \
+                       fdisk --list $Disk \
                        | head --lines=1 | awk \
                        --field-separator="," '{print $2}' \
                        | sed 's/[ \| Bbytes]//g')
                local readonly humanSize=$(SizeHumanReadable "$DiskSize")
 
                printf "DiskSize: %s\n\n" "$humanSize"
-               ssh $remoteLogin dd bs=1M if=$Disk | pv --size $DiskSize \
+               ssh -p $remoteport $remoteLogin dd bs=1M if=$Disk \
+                       | pv --size $DiskSize \
                        | gzip --stdout | dd of=$backRemotePCPath/$DiskName.gz
        fi
 }
 
 BackupVMDiscs()
 {
-       local readonly Disks=$(ssh $remoteLogin virsh domblklist $VM --details \
+       local readonly Disks=$(ssh -p $remoteport $remoteLogin \
+               virsh domblklist $VM --details \
                | grep disk \
                | awk '{print $4}')
        local logFile=""
@@ -138,8 +142,8 @@ BackupVMDiscs()
                printf "Disk ${YELLOW}%s${RESET} von " "$Disk"
                printf "${LIGHTBLUE}%s${RESET} wird gesichert\n\n" "$VM"
 
-               DiskType=$(ssh $remoteLogin virsh vol-info $Disk \
-                       | grep Type | awk '{print $2}')
+               DiskType=$(ssh -p $remoteport $remoteLogin virsh vol-info \
+                       $Disk | grep Type | awk '{print $2}')
                logFile="$backRemotePCPath/backup-$(echo $Disk \
                        | sed 's/\//-/g').log"
                BackupTypOfVMDisc
@@ -155,7 +159,7 @@ WaitVMShutdown()
 
 BackupOnlineVMs()
 {
-       onlineVM=$(ssh $remoteLogin virsh list --name)
+       onlineVM=$(ssh -p $remoteport $remoteLogin virsh list --name)
 
        for VM in $onlineVM; do
                printfStripLine
@@ -163,18 +167,19 @@ BackupOnlineVMs()
                printf "${LIGHTBLUE}%s${RESET} ist " "$VM"
                printf "${LIGHTGREEN}online${RESET}\n"
                printf "Fahre %s herunter\n\n" "$VM"
-               ssh $remoteLogin virsh shutdown $VM | WaitVMShutdown
+               ssh -p $remoteport $remoteLogin virsh shutdown $VM \
+                       | WaitVMShutdown
                BackupVMDiscs
                printf "\nFahre %s hoch\n" "$VM"
-               ssh $remoteLogin virsh start $VM
+               ssh -p $remoteport $remoteLogin virsh start $VM
                printfStripLine
        done
 }
 
 BackupOfflineVMs()
 {
-       offlineVM=$(ssh $remoteLogin virsh list --all | grep 'shut off' \
-               | awk '{print $2}')
+       offlineVM=$(ssh -p $remoteport $remoteLogin virsh list --all \
+               | grep 'shut off' | awk '{print $2}')
 
        for VM in $offlineVM; do
                printfStripLine
@@ -205,8 +210,8 @@ BackupDirectoryPath()
 
        rsync --archive --verbose --sparse --acls --hard-links --relative \
                --human-readable --log-file=$logFile --filter="- *.qcow2" \
-               --filter="- *.raw" $hardlinkopt $remoteLogin:$pfad \
-               $backRemotePCPath
+               --filter="- *.raw" $hardlinkopt --rsh "ssh -p $remoteport" \
+               $remoteLogin:$pfad $backRemotePCPath
        printfStripLine
 }
 
@@ -219,10 +224,11 @@ BackupPackages()
        printf "${YELLOW}Packages${RESET} wird gesichert \n\n"
 
        mkdir --parents $packPath
-       dpkg --get-selections > $packPath/package.list
-       apt-key exportall > $packPath/aptkey
+       ssh -p $remoteport $remoteLogin dpkg --get-selections \
+               > $packPath/package.list
+       ssh -p $remoteport $remoteLogin apt-key exportall > $packPath/aptkey
        rsync --archive --verbose  --log-file=$packPath/aptsources.log \
-               /etc/apt $packPath/
+               --rsh "ssh -p $remoteport" $remoteLogin:/etc/apt $packPath/
        printfStripLine
 }
 
@@ -232,7 +238,7 @@ BackupPathes()
                printf "FEHLER: pfad-%s existiert nicht!\n" "$remoterechner"
        fi
 
-       for pfad in $(cat pfad-$remoterechner.txt); do
+       for pfad in $(cat pfad-$remoterechner); do
                if [ "$pfad" == "virsh" ]; then
                        BackupVMs
                elif [ "$pfad" == "packages" ]; then