56 lines
1.3 KiB
PowerShell
56 lines
1.3 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Run as ADMIN
|
|
Creats Zip-Backup of everything inside Notes folder
|
|
.PARAMETER targetEnv
|
|
the target folder to move zip file to. Possible Values: LOCAL, SWAG, ATB. If no parameter is supplied, the zip file will be located in the same folder as this script.
|
|
.EXAMPLE
|
|
.\backup_notes.ps1 LOCAL
|
|
.NOTES
|
|
Author: Marcel Dechert
|
|
#>
|
|
|
|
param (
|
|
[ValidateSet('LOCAL','SWAG','ATB')]
|
|
[String]
|
|
$targetEnv
|
|
)
|
|
|
|
# Backup Targets
|
|
# 1. Local
|
|
# 2. ATB Network drive
|
|
# 3. Swaghausen Network drive
|
|
$pathToFolder = switch ($targetEnv)
|
|
{
|
|
LOCAL {
|
|
"C:\Users\dechert\Notizen_Backup\"
|
|
}
|
|
SWAG {
|
|
"\\Swaghausen-WG\homes\marcelo\ATB\Notizen-Backups\"
|
|
}
|
|
ATB {
|
|
"https://locmanacc.europoolsystem.com/locman/api/zones"
|
|
}
|
|
}
|
|
|
|
$7zipPath = "$env:ProgramFiles\7-Zip\7z.exe"
|
|
|
|
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
|
|
throw "7 zip file '$7zipPath' not found"
|
|
}
|
|
|
|
Set-Alias 7zip $7zipPath
|
|
|
|
$Source = "C:\Users\dechert\Notizen"
|
|
|
|
$currentDate = get-date -f MM-dd-yyyy_HH_mm_ss
|
|
$targetFilename = "Notizen_Backup_" + $currentDate + ".zip"
|
|
|
|
$target = $pathToFolder + $targetFilename
|
|
|
|
# mx=9 is maximum compression level
|
|
7zip a -mx=9 $target $Source
|
|
|
|
# TODO: use Robocopy to move files to network
|
|
# robocopy $copySourceFolder $copyTargetFolder $target /Z /r:60 /w:5 /MIR /MT:64 /NFL
|