X-Git-Url: https://git.p6c8.net/dsmonrot.git/blobdiff_plain/f83c6ca4a53ca7d80bc2bab3f6c3284588a8d860..HEAD:/dsmonrot.ps1?ds=inline diff --git a/dsmonrot.ps1 b/dsmonrot.ps1 index ddaae59..ffe4f46 100644 --- a/dsmonrot.ps1 +++ b/dsmonrot.ps1 @@ -15,7 +15,7 @@ # This directory MUST exist, it is not created automatically! [String]$backupDir = "Z:\" # Disks to backup, see http://www.drivesnapshot.de/en/commandline.htm -[String]$disksToBackup = "D1:1" +[String]$disksToBackup = "HD1:1" # Path to Drive Snapshot [String]$dsPath = "C:\Users\Patrick\Desktop\DSMonRot\snapshot.exe" # Keep backups for this amount of months (excluding the current month), @@ -42,6 +42,10 @@ # 0 or less for indefinite # You should set this to at least the same as $keepMonths [Int32]$keepLogs = 2 +# Comma separated lists of files and directories to exclude from the backup +# See http://www.drivesnapshot.de/en/commandline.htm +# Comment out if you don't want to use it +#[String]$excludedPaths = "Path1,Path2" # Map network share to this drive letter, comment out if you don't want to use it [String]$smbDrive = "Z" @@ -211,7 +215,7 @@ function Send-Email([String]$body) { } } -function Rotate-Backup { +function Invoke-BackupRotation { if($keepMonths -lt 0) { return } @@ -231,7 +235,7 @@ function Rotate-Backup { } } -function Rotate-Log { +function Invoke-LogRotation { if($keepLogs -le 0) { return } @@ -327,8 +331,13 @@ if($errorMessages.Count -eq 0) { $backupTargetDiff = $backupTargetDiff + "-" + $currTime } + # Compose the "exclude" parameter if necessary + if($excludedPaths) { + $dsAdditionalArgs += "--exclude:" + $excludedPaths + } + # Check if the backup target for this month, the directory for the full backup - # and the hash files exists. In this case we do a differential backup. + # and the hash files exist. In that case we do a differential backup. if((Test-Path $backupTarget) -and (Test-Path $backupTargetFull) -and (Test-Path "$backupTargetFull\*.hsh")) { # Do a differential backup @@ -398,7 +407,7 @@ if($errorMessages.Count -eq 0) { if($errorMessages.Count -eq 0) { if($rotateBeforeBackup) { - Rotate-Backup + Invoke-BackupRotation } $dsLogPath = if($dsLogFileToBackup) { "$backupTargetFull\$dsLogFile" } else { $dsLogFile } @@ -420,7 +429,7 @@ if($errorMessages.Count -eq 0) { } if($rotateBeforeBackup -eq $False -and $success -eq $True) { - Rotate-Backup + Invoke-BackupRotation } } } @@ -441,7 +450,8 @@ if($errorMessages.Count -eq 0) { } # Rotate the log files - Rotate-Log + Invoke-LogRotation + } # If there was any error message recorded, send a mail if configured