]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
refactor restore-einfach
authorBastian Dehn <hhaalo@arcor.de>
Sat, 25 Nov 2017 11:44:33 +0000 (12:44 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 25 Nov 2017 11:50:17 +0000 (12:50 +0100)
restore-einfach

index 6ef7bffa99e140309bd7361148cced99f287e63f..b8d0bac311886a5118fcf122bc78f7e7e455d968 100755 (executable)
@@ -1,30 +1,57 @@
 #!/bin/bash
 
-sicherungspfad="/images/backup"
-sicherungsordner="einfach-sicherung"
-
-while getopts "r:p:" optname; do
-       case "$optname" in
-       "r")
-               rechner="$OPTARG"
-               ;;
-       "p")
-               pfad="$OPTARG"
-               ;;
-       esac
-done
-
-if [ -z "$rechner" ] || [ -z "$pfad" ]; then
-       printf "Es fehlen Parameter!\n"
-       exit 1
-fi
-
-printf "################################################################\n"
-printf "Daten werden wiederhergestellt\n\n"
-printf "Pfad: %s\n" $pfad
-printf "Rechner: %s\n" $rechner
-printf "################################################################\n"
-
-rsync --archive --verbose --sparse --acls --hard-links --human-readable --log-file $sicherungspfad/restore-einfach-$(date +%Y-%m-%d).log $sicherungspfad/$sicherungsordner/$rechner/$pfad root@$rechner:$pfad
+SetDefaultVariables() {
+       sicherungspfad="/images/backup"
+       sicherungsordner="einfach-sicherung"
+}
+
+ReadArguments() {
+       while getopts "r:p:" optname; do
+               case "$optname" in
+               "r")
+                       rechner="$OPTARG"
+                       ;;
+               "p")
+                       pfad="$OPTARG"
+                       ;;
+               esac
+       done
+
+       if [ -z "$rechner" ] || [ -z "$pfad" ]; then
+               printf "Es fehlen Parameter!\n"
+               exit 1
+       fi
+}
+
+printfStripLine() {
+       printf "####################"
+       printf "####################"
+       printf "####################"
+       printf "####################\n"
+}
+
+RestoreData() {
+       remoteLogin="root@$rechner"
+       fullPathSicherungsOrnder="$sicherungspfad/$sicherungsordner"
+
+       printfStripLine
+       printf "Daten werden wiederhergestellt\n\n"
+       printf "Pfad: %s\n" $pfad
+       printf "Rechner: %s\n" $rechner
+       printfStripLine
+
+       rsync --archive --verbose --sparse --acls --hard-links --human-readable \
+               --log-file $sicherungspfad/restore-einfach-$(date +%Y-%m-%d).log \
+               $fullPathSicherungsOrdner/$rechner/$pfad \
+               $remoteLogin:$pfad
+}
+
+main() {
+       SetDefaultVariables
+       ReadArguments $*
+       RestoreData
+}
+
+main $*
 
 exit 0