64 lines
2.4 KiB
PowerShell
64 lines
2.4 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 = "andreasgrote"
|
|
|
|
# Ziele/Quellen
|
|
$quelle1 ="\\nas\backup"
|
|
$quelle2 ="\\nas\bilder"
|
|
$quelle3 ="\\nas\dokumente"
|
|
$quelle4 ="\\nas\musik"
|
|
$quelle5 ="\\nas\videos"
|
|
$quelle6 ="\\nas\rest"
|
|
$quelle1_name ="backup"
|
|
$quelle2_name ="bilder"
|
|
$quelle3_name ="dokumente"
|
|
$quelle4_name ="musik"
|
|
$quelle5_name ="videos"
|
|
$quelle6_name ="rest"
|
|
$ziel1="$scriptpfad\backup\backup"
|
|
$ziel2="$scriptpfad\backup\bilder"
|
|
$ziel3="$scriptpfad\backup\dokumente"
|
|
$ziel4="$scriptpfad\backup\musik"
|
|
$ziel5="$scriptpfad\backup\videos"
|
|
$ziel6="$scriptpfad\backup\rest"
|
|
|
|
|
|
# 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" /XD $quelle1\@recycle $quelle1\@Recently-Snapshot
|
|
robocopy $quelle2 $ziel2 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle2_name.log" /XD $quelle2\@recycle $quelle2\@Recently-Snapshot
|
|
robocopy $quelle3 $ziel3 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle3_name.log" /XD $quelle3\@recycle $quelle3\@Recently-Snapshot
|
|
robocopy $quelle4 $ziel4 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle4_name.log" /XD $quelle4\@recycle $quelle4\@Recently-Snapshot
|
|
robocopy $quelle5 $ziel5 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle5_name.log" /XD $quelle5\@recycle $quelle5\@Recently-Snapshot
|
|
robocopy $quelle6 $ziel6 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle6_name.log" /XD $quelle6\@recycle $quelle6\@Recently-Snapshot
|