新しいNAS(Windows Server IoT)を導入した。バックアップに専用のソフトを導入するほどの規模でもないのでPowerShell+タスクスケジューラにて設定。
-日次ミラーリングデータ*2
-1週間分の差分データ
-月次のミラーリングデータ
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$src = "xxx" $dst1 = "xxx" $dst2 = "xxx" $dif = "xxx" $mon = "xxx" $opt = @("/R:3", "/W:5", "/NP", "/NDL") $today = Get-Date $dayNum = [int]$today.DayOfWeek robocopy $src $dst1 /MIR $opt robocopy $src $dst2 /MIR $opt if ($dayNum -ne 0) { $targetDir = Join-Path $dif $dayNum if (Test-Path $targetDir) { Remove-Item $targetDir -Recurse -Force } New-Item -Path $targetDir -ItemType Directory -Force | Out-Null $lastSunday = $today.AddDays(-$dayNum).ToString("yyyyMMdd") robocopy $src $targetDir /S /MAXAGE:$lastSunday $opt } if ($today.Day -eq 1) { robocopy $src $mon /MIR $opt } |