scripts-n-stuff/backup_notes.ps1
2021-07-08 18:56:38 +02:00

53 lines
1.2 KiB
PowerShell

<#
.SYNOPSIS
Run as ADMIN
Backup everything inside 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-test"
$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