Compare commits

..

2 Commits

Author SHA1 Message Date
dechert
2b385a945d robocopy files to target folder and delete 2021-12-15 16:15:04 +01:00
dechert
a9ca4b0985 update backup notes 2021-12-15 15:44:29 +01:00
2 changed files with 12 additions and 3 deletions

View File

@ -1,2 +1,3 @@
# scripts-n-stuff
Collection of useful powershell and bash scripts

View File

@ -33,6 +33,8 @@ $pathToFolder = switch ($targetEnv)
}
}
Write-Host "Starting to zip notes folder... Target folder will be: $pathToFolder"
$7zipPath = "$env:ProgramFiles\7-Zip\7z.exe"
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
@ -46,9 +48,15 @@ $Source = "C:\Users\dechert\Notizen"
$currentDate = get-date -f MM-dd-yyyy_HH_mm_ss
$targetFilename = "Notizen_Backup_" + $currentDate + ".zip"
$Target = $pathToFolder + $targetFilename
$zipTarget = $targetFilename
# mx=9 is maximum compression level
7zip a -mx=9 $Target $Source
7zip a -mx=9 $zipTarget $Source
# TODO: use Robocopy to move files to network
# use Robocopy to move files to target folder
# robocopy . "\\Swaghausen-WG\homes\marcelo\ATB\Notizen-Backups\" "Notizen_Backup_12-15-2021_15_25_40.zip" /Z /r:60 /w:5 /MIR /MT:64 /NFL
# TODO print progress: https://stackoverflow.com/questions/13883404/custom-robocopy-progress-bar-in-powershell
robocopy . $pathToFolder $zipTarget /Z /r:60 /w:5 /MIR /MT:64 /NFL
# delete zip file in local folder if successfull
Remove-Item $zipTarget