51 lines
2 KiB
PowerShell
51 lines
2 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
|
|
# Hhostname
|
|
$hostname_ist = $env:computername
|
|
$hostname_soll = "andreasgrote"
|
|
|
|
# Ziele/Quellen
|
|
$quelle1 ="\\nas.local\backup\"
|
|
$quelle2 ="\\nas.local\bilder\"
|
|
$quelle3 ="\\nas.local\dokumente\"
|
|
$quelle4 ="\\nas.local\musik\"
|
|
$quelle5 ="\\nas.local\videos"
|
|
$quelle6 ="\\nas.local\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
|
|
}
|
|
|
|
robocopy $quelle1 $ziel1 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\$timestamp.log" /XD $quelle1\@recycle $quelle1\@Recently-snapshot
|
|
robocopy $quelle2 $ziel2 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\$timestamp.log" /XD $quelle2\@recycle $quelle2\@Recently-snapshot
|
|
robocopy $quelle3 $ziel3 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\$timestamp.log" /XD $quelle3\@recycle $quelle3\@Recently-snapshot
|
|
robocopy $quelle4 $ziel4 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\$timestamp.log" /XD $quelle4\@recycle $quelle4\@Recently-snapshot
|
|
robocopy $quelle5 $ziel5 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\$timestamp.log" /XD $quelle5\@recycle $quelle5\@Recently-snapshot
|
|
robocopy $quelle6 $ziel6 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\$timestamp.log" /XD $quelle6\@recycle $quelle6\@Recently-snapshot
|