wip
This commit is contained in:
parent
1738016bb2
commit
4a25cbcbe9
2 changed files with 19 additions and 74 deletions
|
@ -1,46 +1,37 @@
|
|||
#Variablen
|
||||
#Variablen setzen
|
||||
#variablendeklaration pfade
|
||||
#scriptpfad ermitteln
|
||||
#funktion get-scriptdirectory definieren
|
||||
# Setze Scriptpfad
|
||||
function Get-ScriptDirectory {
|
||||
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
||||
Split-Path $Invocation.MyCommand.Path
|
||||
}
|
||||
#funktion an variable zuweisen
|
||||
# Setze Timestamp
|
||||
function get-timestamp{
|
||||
$timestamp = (get-date -Format yyyy_MM_dd__HH_mm_ss)
|
||||
return $timestamp
|
||||
}
|
||||
|
||||
# Variablen
|
||||
$scriptpfad = Get-ScriptDirectory
|
||||
#hostname
|
||||
$restic_path= Join-Path $scriptpfad bin\restic.exe
|
||||
$timestamp = get-timestamp
|
||||
$hostname_ist = $env:computername
|
||||
$hostname_soll = "irantu"
|
||||
|
||||
#### restic ####
|
||||
### repository
|
||||
$logfile_dir="\\fileserver2.grote.lan\backup\restic\logs"
|
||||
$logfile_name=-join($hostname_ist,"_",$timestamp,".log")
|
||||
$repository="\\fileserver2.grote.lan\backup\restic"
|
||||
### ordner fuer sicherung
|
||||
$ordner1="C:\Users\mg"
|
||||
$ordner2="C:\Portable_Programme"
|
||||
$ordner3=""
|
||||
$ordner4=""
|
||||
$ordner5=""
|
||||
### passwordfile
|
||||
$passwordfile="C:\Users\mg\Desktop\NextCloud\Programme\restic\config\password.txt"
|
||||
### exclude file
|
||||
$excludefile="C:\Users\mg\Desktop\NextCloud\Programme\restic\config\exclude.txt"
|
||||
### aktion/befehl
|
||||
$befehl="backup"
|
||||
$ordner="C:\Users\mg C:\Portable_Programme"
|
||||
|
||||
|
||||
# Hostname pruefen
|
||||
if ($hostname_ist -eq $hostname_soll)
|
||||
{
|
||||
Write-Host "Host = $hostname_ist"
|
||||
& $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
|
||||
else
|
||||
{
|
||||
Write-Host "Falscher Host(SOLL: '$hostname_soll' IST:$hostname_ist)"
|
||||
Write-Host "Falscher Host(SOLL: $hostname_soll IST: $hostname_ist)"
|
||||
start-sleep 5
|
||||
Exit 1
|
||||
}
|
||||
|
||||
# $LastExitCode
|
||||
|
||||
|
||||
C:\Users\mg\Desktop\NextCloud\Programme\restic\bin\restic.exe -r $repository --password-file $passwordfile $befehl --exclude-file $excludefile $ordner1 $ordner2 $ordner3 $ordner4 $ordner5
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
#Variablen
|
||||
#Variablen setzen
|
||||
#variablendeklaration pfade
|
||||
#scriptpfad ermitteln
|
||||
#funktion get-scriptdirectory definieren
|
||||
function Get-ScriptDirectory {
|
||||
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
||||
Split-Path $Invocation.MyCommand.Path
|
||||
}
|
||||
#funktion an variable zuweisen
|
||||
$scriptpfad = Get-ScriptDirectory
|
||||
#hostname
|
||||
$hostname_ist = $env:computername
|
||||
$hostname_soll = "tetraskelion"
|
||||
|
||||
#### restic ####
|
||||
### repository
|
||||
$repository="\\fileserver2.grote.lan\backup\restic"
|
||||
### ordner fuer sicherung
|
||||
$ordner1="C:\Portabel"
|
||||
$ordner2="C:\Users\mg\Desktop"
|
||||
$ordner3="C:\Users\mg\AppData\Roaming\StardewValley"
|
||||
$ordner4=""
|
||||
$ordner5=""
|
||||
### passwordfile
|
||||
$passwordfile="C:\Users\mg\Desktop\NextCloud\Programme\restic\config\password.txt"
|
||||
### exclude file
|
||||
$excludefile="C:\Users\mg\Desktop\NextCloud\Programme\restic\config\exclude.txt"
|
||||
### aktion/befehl
|
||||
$befehl="backup"
|
||||
|
||||
|
||||
# Hostname pruefen
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
C:\Users\mg\Desktop\NextCloud\Programme\restic\bin\restic.exe -r $repository --password-file $passwordfile $befehl --exclude-file $excludefile $ordner1 $ordner2 $ordner3 $ordner4 $ordner5
|
Loading…
Add table
Reference in a new issue