103 lines
4.9 KiB
PowerShell
103 lines
4.9 KiB
PowerShell
#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
|
|
$repository="\\fileserver.grote.lan\Backup\restic"
|
|
### 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"
|
|
|
|
#ausgabe der varriablen und einfaerben der werte mit -foregroundcolor
|
|
#`n ist zeilenumbruch
|
|
write-host "===================================="
|
|
write-host "Repository: "
|
|
write-host -ForegroundColor Yellow $repository
|
|
write-host "Pfad zu Restic: "
|
|
write-host -ForegroundColor Yellow $pfad
|
|
write-host "Passworddatei: "
|
|
write-host -ForegroundColor Yellow $passwordfile
|
|
write-host "===================================="
|
|
write-host -ForegroundColor Red "Auschluesse: "
|
|
get-content $excludefile
|
|
write-host "====================================`n`n"
|
|
|
|
do
|
|
{
|
|
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`n10 = Restore - alles bis auf bestimmte Daten"
|
|
Write-Host "11 = Snapshot loeschen`n12 = Rebuild-Index`n13 = Statistiken - Groesse nach wiederherstellen`n14 = Statistiken - Groesse auf Storage"
|
|
Write-Host "15 = Cache leeren`n99 = Beenden"
|
|
write-host "===================================="
|
|
$aktion = Read-Host
|
|
switch ($aktion)
|
|
# switch, default faengt alle nicht eingetragen eingaben ab
|
|
{
|
|
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}
|
|
5 {
|
|
$befehl=Read-Host -Prompt "Befehl?";
|
|
& $pfad -r $repository --password-file $passwordfile $befehl;
|
|
break
|
|
}
|
|
99 {exit;break}
|
|
6 {& $pfad -r $repository --password-file $passwordfile unlock; break}
|
|
7 {
|
|
$befehl=Read-Host -Prompt "Befehl?";
|
|
write-host -nonewline $pfad -r $repository --password-file $passwordfile $befehl`n;
|
|
break
|
|
}
|
|
8 {
|
|
$snapshot = read-host -Prompt "Snapshot(latest/id)";
|
|
$target = read-host -Prompt "Zielpfad: ";
|
|
& $pfad -r $repository --password-file $passwordfile restore $snapshot --target $target
|
|
}
|
|
9 {
|
|
$snapshot = read-host -Prompt "Snapshot(latest/id)";
|
|
$target = read-host -Prompt "Zielpfad: ";
|
|
write-host "Include: "
|
|
write-host "===================================="
|
|
write-host -Foregroundcolor red "Beispiele: "
|
|
write-host -ForegroundColor yellow "Dateitypen: *.exe`nDatei: C\Users\mg\Desktop\rclone\datei.exe`nOrdner: 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 {
|
|
$snapshot = read-host -Prompt "Snapshot(latest/id)";
|
|
$target = read-host -Prompt "Zielpfad: ";
|
|
$exclude = read-host -Prompt "Exclude: ";
|
|
& $pfad -r $repository --password-file $passwordfile restore $snapshot --target $target --exclude $exclude
|
|
}
|
|
11 {
|
|
$snapshot = read-host -Prompt "Snapshot(latest/id)";
|
|
& $pfad -r $repository --password-file $passwordfile forget $snapshot
|
|
}
|
|
12 {& $pfad -r $repository --password-file $passwordfile rebuild-index ; break}
|
|
13 {& $pfad -r $repository --password-file $passwordfile stats --mode restore-size ; break}
|
|
14 {& $pfad -r $repository --password-file $passwordfile stats --mode raw-data ; break}
|
|
15 {& $pfad -r $repository --password-file $passwordfile cache --cleanup ; break}
|
|
|
|
default{write-host "`nUngueltige Eingabe!"}
|
|
|
|
}
|
|
#der auskommentiert absatz ist ob nochmal extra gefragt werden soll ob das script weiterausgefuehrt werden soll, entfaellt da option 99 jetzt beende ist
|
|
#write-host "===================================="
|
|
#Write-Host "Abbrechen (j/n)?"
|
|
#write-host "===================================="
|
|
#$abbrechen = read-host
|
|
}
|
|
#while($abbrechen -eq "n")
|
|
#fuehrt die schleife immer wieder aus
|
|
while (1 -eq 1)
|