Nathan Durnan avatar Nathan Durnan committed d347614

Add in Setting for PurgeBackups.
Reopen Issue #4 at BitBucket

Comments (0)

Files changed (4)

 .hgignore,1326153052.39
 .hgsub,1325791137.19
 .hgsubstate,1325791876.03
-_HgPreBackup.au3,1326759193.05
+_HgPreBackup.au3,1326760509.09
 HgPreBackup.ico,1325031982.39
 HgPreBackup.svg,1325032006.66
 HgPreBackup_x64.exe,1326752358.3
 HgPreBackup_x86.exe,1326752352.0
-HgPreBackupSettings.ini,1326749875.39
-README.rst,1326752112.33
+HgPreBackupSettings.ini,1326759741.89
+README.rst,1326760580.3

HgPreBackupSettings.ini

 ;       e.g. at least 30 days worth of logs, AND at least 10 logs.
 ;       The more generous condition will always take precedence to 
 ;       preserve the maximum amount of historical log information.
+;  PurgeBackups ..: Remove backup repositories when they no longer have
+;                   matching source repositories.
+;                   Expected Values: 'True' or 'False'
+;                       True  -> Send orphaned backups to Recycle Bin.
+;                       False -> Leave orphaned backups in BackupPath.
 ;----------------------------------------------------------------------
 SubFolderLimit = 10
 Report = False
 KeepLogCount = 10
 KeepLogDays = 30
+PurgeBackups = False
 ;End of Settings
 [email]
 ;----------------------------------------------------------------------
   - 'KeepLogDays = -1' will keep ALL log files (regardless of KeepLogCount setting)
   
 **NOTE:** The KeepLog... settings work in combinaton with each other:
-    e.g. at least 30 days worth of logs, AND at least 10 logs.
-    The more generous condition will always take precedence to 
-    preserve the maximum amount of historical log information.
+  e.g. at least 30 days worth of logs, AND at least 10 logs.
+  The more generous condition will always take precedence to 
+  preserve the maximum amount of historical log information.
+
+* **PurgeBackups** - Remove backup repositories when they no longer have
+  matching source repositories.  This typically is the result of a source
+  repository being deleted or renamed.  "Orphaned" repositories will likely
+  be taking up unnecessary space in the backup project.
+
+  - Expected Values: 'True' or 'False'
+  
+    + True = Send orphaned backups to Recycle Bin.
+    + False = Leave orphaned backups in BackupPath.
+
 
 [Email] Settings
 ~~~~~~~~~~~~~~~~
 
 Dependencies
 ~~~~~~~~~~~~
-* Microsoft Script Runtime (scrrun.dll)
+* Microsoft Script Runtime (scrrun.dll)
 
   - Developed using Version 5.7.0.18066
 
-* Windows NT BASE API Client DLL (kernel32.dll)
+* Windows NT BASE API Client DLL (kernel32.dll)
 
   - Developed using Version 5.1.2600.5781
 
-* Microsoft CDO for Windows Library (cdosys.dll)
+* Microsoft CDO for Windows Library (cdosys.dll)
 
   - Developed using Version 6.2.4.0
 
 Global $Gh_LogFile 			;Handle for log file
 Global $Gi_KeepLogCount		;Number of old logs to keep in log path.
 Global $Gi_KeepLogDays		;Days of old logs to keep in log path.
+Global $Gb_PurgeBackups		;Purge Orphaned Backups that no longer have a source repository.
 
 Global $Ga_RepoList[1]				;Array containing paths of repositories to be backed up.
 Global $Ga_RepoValidErr[1]			;Array containing list of source repositories that failed validation.
 	$myResult = $myResult And FileWriteLine($hFile, ";       e.g. at least 30 days worth of logs, AND at least 10 logs.")
 	$myResult = $myResult And FileWriteLine($hFile, ";       The more generous condition will always take precedence to ")
 	$myResult = $myResult And FileWriteLine($hFile, ";       preserve the maximum amount of historical log information.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  PurgeBackups ..: Remove backup repositories when they no longer have")
+	$myResult = $myResult And FileWriteLine($hFile, ";                   matching source repositories.")
+	$myResult = $myResult And FileWriteLine($hFile, ";                   Expected Values: 'True' or 'False'")
+	$myResult = $myResult And FileWriteLine($hFile, ";                       True  -> Send orphaned backups to Recycle Bin.")
+	$myResult = $myResult And FileWriteLine($hFile, ";                       False -> Leave orphaned backups in BackupPath.")
 	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
 	$myResult = $myResult And FileWriteLine($hFile, "SubFolderLimit = " & $Gi_RecurseLimit)
 	$myResult = $myResult And FileWriteLine($hFile, "Report = " & $Gb_ReportErrors)
 	$myResult = $myResult And FileWriteLine($hFile, "KeepLogCount = " & $Gi_KeepLogCount)
 	$myResult = $myResult And FileWriteLine($hFile, "KeepLogDays = " & $Gi_KeepLogDays)
+	$myResult = $myResult And FileWriteLine($hFile, "PurgeBackups = " & $Gb_PurgeBackups)
 	$myResult = $myResult And FileWriteLine($hFile, ";End of Settings")
 	$myResult = $myResult And FileWriteLine($hFile, "[email]")
 	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
 	Else ;use default value
 		$Gi_KeepLogDays = -1
 	EndIf ;check for valid value in setting
+	$bValue = IniRead($IN_sSettingsFilePath, 'settings', 'PurgeBackups', False)
+	;Validate Setting Value
+	If IsBool ($bValue) Then
+		$Gb_PurgeBackups = $bValue
+	ElseIf IsString($bValue) Or IsNumber($bValue) Then
+		Switch $bValue
+		Case 't', 'true', 1, -1
+			$Gb_PurgeBackups = True
+		Case Else
+			$Gb_PurgeBackups = False
+		EndSwitch
+	Else
+		$Gb_PurgeBackups = False
+	EndIf
 	#EndRegion Read Settings
 	#Region Read Email Configuration:
 	;NOTE: The default settings will probably not work if the IniRead command fails to retrieve data from the file.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.