85 lines
3.3 KiB
PowerShell
85 lines
3.3 KiB
PowerShell
# Funktion: speichert den aktuellen Pfad(vgl. pwd) in Get-ScriptDirectory
|
|
function Get-ScriptDirectory {
|
|
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
|
Split-Path $Invocation.MyCommand.Path
|
|
}
|
|
|
|
# Funktion: setze Timestamp, mit Rückgabewert
|
|
function get-timestamp{
|
|
$timestamp = (get-date -Format yyyy_MM_dd__HH_mm_ss)
|
|
return $timestamp
|
|
}
|
|
|
|
# restliche Variablen
|
|
$timestamp = get-timestamp # Ruft Funktion get-timestamp auf
|
|
$scriptpfad = Get-ScriptDirectory # setzt $scriptpfad auf den Wert von Get-ScriptDirectory
|
|
# Hostname
|
|
$hostname_ist = $env:computername
|
|
$hostname_soll = "irantu"
|
|
|
|
|
|
# Ziele/Quellen
|
|
$quelle1 ="\\fileserver2.grote.lan\buecher"
|
|
$quelle2 ="\\fileserver2.grote.lan\Musik"
|
|
$quelle3 ="\\fileserver2.grote.lan\amd"
|
|
$quelle4 ="\\fileserver2.grote.lan\backup"
|
|
$quelle5 ="\\fileserver2.grote.lan\archiv"
|
|
$quelle6 ="\\fileserver2.grote.lan\programme"
|
|
$quelle7 ="\\fileserver2.grote.lan\bilder"
|
|
$quelle8 ="\\fileserver2.grote.lan\proxmox"
|
|
$quelle9 ="\\fileserver2.grote.lan\vm"
|
|
$quelle10 ="\\fileserver2.grote.lan\hm"
|
|
$quelle11 ="\\fileserver2.grote.lan\tmp"
|
|
$quelle1_name= "buecher"
|
|
$quelle2_name= "musik"
|
|
$quelle3_name= "amd"
|
|
$quelle4_name= "backup"
|
|
$quelle5_name= "archiv"
|
|
$quelle6_name= "programme"
|
|
$quelle7_name= "bilder"
|
|
$quelle8_name= "proxmox"
|
|
$quelle9_name= "vm"
|
|
$quelle10_name= "hm"
|
|
$quelle11_name= "tmp"
|
|
$ziel1="$scriptpfad\backup\buecher"
|
|
$ziel2="$scriptpfad\backup\Musik"
|
|
$ziel3="$scriptpfad\backup\amd"
|
|
$ziel4="$scriptpfad\backup\backup"
|
|
$ziel5="$scriptpfad\backup\archiv"
|
|
$ziel6="$scriptpfad\backup\programme"
|
|
$ziel7="$scriptpfad\backup\bilder"
|
|
$ziel8="$scriptpfad\backup\proxmox"
|
|
$ziel9="$scriptpfad\backup\vm"
|
|
$ziel10="$scriptpfad\backup\hm"
|
|
$ziel11="$scriptpfad\backup\tmp"
|
|
|
|
# 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
|
|
}
|
|
|
|
# logs Ordner erstellen
|
|
If(!(test-path $scriptpfad\logs))
|
|
{
|
|
New-Item -ItemType Directory -Force -Path $scriptpfad\logs
|
|
}
|
|
|
|
|
|
robocopy $quelle1 $ziel1 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle1_name.log"
|
|
robocopy $quelle2 $ziel2 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle2_name.log"
|
|
robocopy $quelle3 $ziel3 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle3_name.log"
|
|
robocopy $quelle4 $ziel4 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle4_name.log"
|
|
robocopy $quelle5 $ziel5 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle5_name.log"
|
|
robocopy $quelle6 $ziel6 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle6_name.log" /XD "\\fileserver2.grote.lan\mg\Programme\Spiele - nicht gesichert"
|
|
robocopy $quelle7 $ziel7 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle7_name.log"
|
|
robocopy $quelle8 $ziel8 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle8_name.log"
|
|
robocopy $quelle9 $ziel9 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle9_name.log" /XD "\\fileserver2.grote.lan\vm\Mint_lol"
|
|
robocopy $quelle10 $ziel10 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle10_name.log"
|
|
robocopy $quelle11 $ziel811/MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle11_name.log"
|