From: Patrick Canterino Date: Fri, 24 Mar 2023 16:43:04 +0000 (+0100) Subject: Allow to exclude files and directories from the backup X-Git-Url: https://git.p6c8.net/dsmonrot.git/commitdiff_plain/74f77c278c8a2ccc65a174eed00a444fd1b5e378 Allow to exclude files and directories from the backup Options are directly passed to Drive Snapshot's `--exclude` parameter Fixes GitHub issue #2 --- diff --git a/dsmonrot.ps1 b/dsmonrot.ps1 index 7012cf1..8cefa45 100644 --- a/dsmonrot.ps1 +++ b/dsmonrot.ps1 @@ -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" @@ -327,6 +331,11 @@ 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. if((Test-Path $backupTarget) -and (Test-Path $backupTargetFull) -and (Test-Path "$backupTargetFull\*.hsh")) {