66 lines
2.1 KiB
PowerShell
66 lines
2.1 KiB
PowerShell
#funktion get-scriptdirectory definieren um den scriptpfad ermitteln
|
|
function Get-ScriptDirectory {
|
|
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
|
Split-Path $Invocation.MyCommand.Path
|
|
}
|
|
#funktion an variable zuweisen
|
|
$scriptpfad = Get-ScriptDirectory
|
|
#hostname
|
|
$hostname_ist = $env:computername
|
|
$hostname_soll = "irantu"
|
|
#ziele/quellen
|
|
$quelle1 ="\\fileserver2.grote.lan\mg\"
|
|
$ziel1="$scriptpfad\backup\mg"
|
|
$quelle2 ="\\fileserver2.grote.lan\Musik\"
|
|
$ziel2="$scriptpfad\backup\Musik"
|
|
$quelle3 ="\\fileserver2.grote.lan\amd\"
|
|
$ziel3="$scriptpfad\backup\amd"
|
|
$quelle4 ="\\fileserver2.grote.lan\backup\"
|
|
$ziel4="$scriptpfad\backup\backup"
|
|
$quelle5 ="\\fileserver2.grote.lan\Videos\Filme - ueberragende"
|
|
$ziel5="$scriptpfad\backup\Videos\Filme - ueberragende"
|
|
$quelle6 ="\\fileserver2.grote.lan\Videos\Serien - überragende"
|
|
$ziel6="$scriptpfad\backup\Videos\Serien - ueberragende"
|
|
$quelle7 ="\\fileserver2.grote.lan\bilder"
|
|
$ziel7="$scriptpfad\backup\bilder"
|
|
$quelle8 =""
|
|
$ziel8=""
|
|
$quelle9 ="\\fileserver2.grote.lan\proxmox"
|
|
$ziel9="$scriptpfad\backup\proxmox"
|
|
|
|
# Hostname prüfen
|
|
if ($hostname_ist -eq $hostname_soll)
|
|
{
|
|
Write-Host "Host = $hostname_ist"
|
|
}
|
|
else
|
|
{
|
|
Write-Host "Falscher Host(SOLL: '$hostname_soll' IST:$hostname_ist)"
|
|
start-sleep 5
|
|
Exit 1
|
|
}
|
|
|
|
robocopy $quelle1 $ziel1 /MIR /R:3 /W:10 /XD "\\fileserver2.grote.lan\mg\Programme\Spiele - nicht gesichert"
|
|
robocopy $quelle2 $ziel2 /MIR /R:3 /W:10
|
|
robocopy $quelle3 $ziel3 /MIR /R:3 /W:10
|
|
robocopy $quelle4 $ziel4 /MIR /R:3 /W:10
|
|
robocopy $quelle5 $ziel5 /MIR /R:3 /W:10
|
|
robocopy $quelle6 $ziel6 /MIR /R:3 /W:10
|
|
robocopy $quelle7 $ziel7 /MIR /R:3 /W:10
|
|
robocopy $quelle8 $ziel8 /MIR /R:3 /W:10
|
|
robocopy $quelle9 $ziel9 /MIR /R:3 /W:10
|
|
|
|
#Rückgabecoce robocopy auswerten
|
|
#robocopy exit codes
|
|
#https://support.microsoft.com/en-us/help/954404/return-codes-that-are-used-by-the-robocopy-utility-in-windows-server-2
|
|
if ($lastexitcode -eq 1)
|
|
{
|
|
write-host "Keine Fehler!"
|
|
}
|
|
else
|
|
{
|
|
#`n ist newline
|
|
write-host `n`n`n`n`n`n`n`n`n`n`n`n"Es sind Fehler aufgetreten!"`n`n`n`n`n`n`n`n`n`n`n`n
|
|
start-sleep 43200
|
|
}
|