]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add: restore script
authorBastian Dehn <hhaalo@arcor.de>
Sun, 2 Jul 2017 16:18:36 +0000 (18:18 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 2 Jul 2017 16:30:17 +0000 (18:30 +0200)
restore [new file with mode: 0755]

diff --git a/restore b/restore
new file mode 100755 (executable)
index 0000000..4399b4a
--- /dev/null
+++ b/restore
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+sicherungspfad="/images/backup"
+sicherungsname="sicherung"
+
+while getopts "d:r:p:" optname; do
+       case "$optname" in
+       "d")
+               datum="$OPTARG"
+               ;;
+       "r")
+               rechner="$OPTARG"
+               ;;
+       "p")
+               pfad="$OPTARG"
+               ;;
+       esac
+done
+
+if [ -z "$datum" ] || [ -z "$rechner" ] || [ -z "$pfad" ]; then
+       printf "Es fehlen Parameter!\n"
+       exit 1
+fi
+
+sicherungsordner="$datum"_"$sicherungsname"
+printf "################################################################\n"
+printf "Daten werden wiederhergestellt\n\n"
+printf "Pfad: %s\n" $pfad
+printf "Rechner: %s\n\n" $rechner
+printf "von der Sicherung vom %s\n" $datum
+printf "################################################################\n"
+
+rsync --archive --verbose --sparse --acls --hard-links --human-readable --log-file $sicherungspfad/restore-$(date +%Y-%m-%d).log $sicherungspfad/$sicherungsordner/$rechner/$pfad root@$rechner:$pfad
+
+exit 0