#!/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