37 lines
No EOL
1.1 KiB
PowerShell
37 lines
No EOL
1.1 KiB
PowerShell
# Setze Scriptpfad
|
|
function Get-ScriptDirectory {
|
|
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
|
Split-Path $Invocation.MyCommand.Path
|
|
}
|
|
# Setze Timestamp
|
|
function get-timestamp{
|
|
$timestamp = (get-date -Format yyyy_MM_dd__HH_mm_ss)
|
|
return $timestamp
|
|
}
|
|
|
|
# Variablen
|
|
$scriptpfad = Get-ScriptDirectory
|
|
$restic_path= Join-Path $scriptpfad bin\restic.exe
|
|
$timestamp = get-timestamp
|
|
$hostname_ist = $env:computername
|
|
$hostname_soll = "irantu"
|
|
$logfile_dir="\\fileserver2.grote.lan\backup\restic\logs"
|
|
$logfile_name=-join($hostname_ist,"_",$timestamp,".log")
|
|
$repository="\\fileserver2.grote.lan\backup\restic"
|
|
$ordner="C:\Users\mg C:\Portable_Programme"
|
|
|
|
|
|
if ($hostname_ist -eq $hostname_soll)
|
|
{
|
|
& $restic_path --cleanup-cache --repo $repository --password-file $scriptpfad\config\password.txt backup --exclude-file $scriptpfad\config\exclude.txt C:\Users\mg C:\Portable_Programme | Tee-Object -FilePath $logfile_dir\$logfile_name
|
|
}
|
|
else
|
|
{
|
|
Write-Host "Falscher Host(SOLL: $hostname_soll IST: $hostname_ist)"
|
|
start-sleep 5
|
|
Exit 1
|
|
}
|
|
|
|
# $LastExitCode
|
|
|
|
|