2020-04-14 19:51:48 +02:00
#scriptpfad ermitteln
function Get-ScriptDirectory {
$Invocation = ( Get-Variable MyInvocation -Scope 1 ) . Value
Split-Path $Invocation . MyCommand . Path
}
$scriptpfad = Get-ScriptDirectory
#restic variablen
### pfad zu restic, wird mit & $pfad aufgerufen
$pfad = " C:\Users\mg\Desktop\NextCloud\Programme\restic\bin\restic.exe "
### repository
2020-04-20 16:24:13 +02:00
$repository = " \\fileserver.grote.lan\Backup\restic "
2020-04-14 19:51:48 +02:00
### passwordfile
$passwordfile = " C:\Users\mg\Desktop\NextCloud\Programme\restic\config\password.txt "
### exclude file
$excludefile = " C:\Users\mg\Desktop\NextCloud\Programme\restic\config\exclude.txt "
2020-05-11 10:38:20 +02:00
#ausgabe der varriablen und einfaerben der werte mit -foregroundcolor
2020-04-14 19:51:48 +02:00
#`n ist zeilenumbruch
write-host " ==================================== "
2020-04-26 19:01:26 +02:00
write-host " Repository: "
2020-04-14 19:51:48 +02:00
write-host -ForegroundColor Yellow $repository
2020-04-26 19:01:26 +02:00
write-host " Pfad zu Restic: "
2020-04-14 19:51:48 +02:00
write-host -ForegroundColor Yellow $pfad
2020-04-26 19:01:26 +02:00
write-host " Passworddatei: "
2020-04-14 19:51:48 +02:00
write-host -ForegroundColor Yellow $passwordfile
write-host " ==================================== "
2020-05-11 10:38:20 +02:00
write-host -ForegroundColor Red " Auschluesse: "
2020-04-14 19:51:48 +02:00
get-content $excludefile
write-host " ==================================== `n `n "
2020-04-26 19:01:26 +02:00
do
2020-04-14 19:51:48 +02:00
{
write-host " ==================================== "
write-host " Befehl eingeben: "
Write-Host " 1 = Check `n 2 = Forget(Standard...) `n 3 = Prune `n 4 = Snapshots anzeigen `n 5 = Befehl absetzen `n 6 = unlock `n 7 = Befehlszeile ausgeben "
Write-Host " 8 = Restore - komplett `n 9 = Restore - nur bestimmte Daten `n 10 = Restore - alles bis auf bestimmte Daten "
2020-05-11 10:38:20 +02:00
Write-Host " 11 = Snapshot loeschen `n 12 = Rebuild-Index `n 13 = Statistiken - Groesse nach wiederherstellen `n 14 = Statistiken - Groesse auf Storage `n 99 = Beenden "
2020-04-14 19:51:48 +02:00
write-host " ==================================== "
$aktion = Read-Host
switch ( $aktion )
2020-05-11 10:38:20 +02:00
# switch, default faengt alle nicht eingetragen eingaben ab
2020-04-14 19:51:48 +02:00
{
1 { & $pfad -r $repository - -password -file $passwordfile check ; break }
2 { & $pfad -r $repository - -password -file $passwordfile forget - -keep -daily 7 - -keep -weekly 5 - -keep -monthly 12 - -keep -yearly 5 ; break }
3 { & $pfad -r $repository - -password -file $passwordfile prune ; break }
4 { & $pfad -r $repository - -password -file $passwordfile snapshots ; break }
2020-04-26 19:01:26 +02:00
5 {
2020-04-14 19:51:48 +02:00
write-host " Befehl? " ;
$befehl = Read-Host ;
2020-04-26 19:01:26 +02:00
& $pfad -r $repository - -password -file $passwordfile $befehl ;
2020-04-14 19:51:48 +02:00
break
}
99 { exit ; break }
6 { & $pfad -r $repository - -password -file $passwordfile unlock ; break }
2020-04-26 19:01:26 +02:00
7 {
2020-04-14 19:51:48 +02:00
write-host " Befehl? " ;
$befehl = Read-Host ;
write-host -nonewline $pfad -r $repository - -password -file $passwordfile $befehl ;
2020-04-26 19:01:26 +02:00
write-host ` n
2020-04-14 19:51:48 +02:00
break
2020-04-26 19:01:26 +02:00
}
2020-04-14 19:51:48 +02:00
8 {
write-host " Snapshot(latest/id) "
$snapshot = read-host
write-host " Zielpfad: "
$target = read-host
2020-04-26 19:01:26 +02:00
& $pfad -r $repository - -password -file $passwordfile restore $snapshot - -target $target
2020-04-14 19:51:48 +02:00
}
9 {
write-host " Snapshot(latest/id) "
$snapshot = read-host
write-host " Zielpfad: "
$target = read-host
write-host " Include: "
write-host " ==================================== "
write-host -Foregroundcolor red " Beispiele: "
write-host -ForegroundColor yellow " Dateitypen: *.exe `n Datei: C\Users\mg\Desktop\rclone\datei.exe `n Ordner: C\Users\mg\Desktop\rclone\ "
write-host " Alles ist Case-Sensitive! "
write-host " ==================================== "
$include = read-host
& $pfad -r $repository - -password -file $passwordfile restore $snapshot - -target $target - -include $include
}
10 {
write-host " Snapshot(latest/id) "
$snapshot = read-host
write-host " Zielpfad: "
$target = read-host
write-host " Exclude: "
$exclude = read-host
& $pfad -r $repository - -password -file $passwordfile restore $snapshot - -target $target - -exclude $exclude
}
2020-04-26 19:01:26 +02:00
11 {
2020-04-14 19:51:48 +02:00
write-host " Snapshot(latest/id) "
$snapshot = read-host
& $pfad -r $repository - -password -file $passwordfile forget $snapshot
}
2020-04-26 19:01:26 +02:00
12 { & $pfad -r $repository - -password -file $passwordfile rebuild-index ; break }
2020-05-04 14:29:05 +02:00
13 { & $pfad -r $repository - -password -file $passwordfile stats - -mode restore-size ; break }
14 { & $pfad -r $repository - -password -file $passwordfile stats - -mode raw-data ; break }
2020-05-11 10:38:20 +02:00
default { write-host " `n Ungueltige Eingabe! " }
2020-04-14 19:51:48 +02:00
}
2020-05-11 10:38:20 +02:00
#der auskommentiert absatz ist ob nochmal extra gefragt werden soll ob das script weiterausgefuehrt werden soll, entfaellt da option 99 jetzt beende ist
2020-04-14 19:51:48 +02:00
#write-host "===================================="
#Write-Host "Abbrechen (j/n)?"
#write-host "===================================="
#$abbrechen = read-host
}
#while($abbrechen -eq "n")
2020-05-11 10:38:20 +02:00
#fuehrt die schleife immer wieder aus
2020-04-14 19:51:48 +02:00
while ( 1 -eq 1 )