restic/backup_irantu.ps1

37 lines
1.1 KiB
PowerShell
Raw Normal View History

2021-04-22 22:04:14 +02:00
# Setze Scriptpfad
2020-07-09 10:40:38 +02:00
function Get-ScriptDirectory {
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
2021-04-22 22:04:14 +02:00
# Setze Timestamp
function get-timestamp{
$timestamp = (get-date -Format yyyy_MM_dd__HH_mm_ss)
return $timestamp
}
# Variablen
2020-07-09 10:40:38 +02:00
$scriptpfad = Get-ScriptDirectory
2021-04-22 22:04:14 +02:00
$restic_path= Join-Path $scriptpfad bin\restic.exe
$timestamp = get-timestamp
2020-07-09 10:40:38 +02:00
$hostname_ist = $env:computername
$hostname_soll = "irantu"
2021-04-22 22:04:14 +02:00
$logfile_dir="\\fileserver2.grote.lan\backup\restic\logs"
$logfile_name=-join($hostname_ist,"_",$timestamp,".log")
2020-07-19 12:52:04 +02:00
$repository="\\fileserver2.grote.lan\backup\restic"
2021-04-22 22:04:14 +02:00
$ordner="C:\Users\mg C:\Portable_Programme"
2020-07-09 10:40:38 +02:00
2021-04-22 22:04:14 +02:00
if ($hostname_ist -eq $hostname_soll)
2020-07-09 10:40:38 +02:00
{
2021-04-22 22:04:14 +02:00
& $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
2020-07-09 10:40:38 +02:00
}
2021-04-22 22:04:14 +02:00
else
2020-07-09 10:40:38 +02:00
{
2021-04-22 22:04:14 +02:00
Write-Host "Falscher Host(SOLL: $hostname_soll IST: $hostname_ist)"
2020-07-09 10:40:38 +02:00
start-sleep 5
Exit 1
}
2021-04-22 22:04:14 +02:00
# $LastExitCode
2020-07-09 10:40:38 +02:00
2021-04-22 22:04:14 +02:00