Nathan Durnan avatar Nathan Durnan committed e5f31ad Merge

Merge with Development

Comments (0)

Files changed (4)

-_HgPreBackup.au3,1326144636.63
-HgPreBackup_x86.exe,1326144627.0
-HgPreBackup_x64.exe,1326144633.78
+.hgignore,1326153052.39
 .hgsub,1325791137.19
-HgPreBackupSettings.ini,1325896705.95
 .hgsubstate,1325791876.03
-README.rst,1325791389.33
+_HgPreBackup.au3,1326752363.95
 HgPreBackup.ico,1325031982.39
 HgPreBackup.svg,1325032006.66
-.hgignore,1326153052.39
-.hgtimestamp,1326153146.55
+HgPreBackup_x64.exe,1326752358.3
+HgPreBackup_x86.exe,1326752352.0
+HgPreBackupSettings.ini,1326749875.39
+README.rst,1326752112.33

HgPreBackupSettings.ini

 [settings]
 ;----------------------------------------------------------------------
 ;This section is where general preferences are specified.
+;  SubFolderLimt .: Maxmum number of subfolders to check within RepoPath.
 ;  Report ..: Send email of log file if errors are encountered.
 ;             Expected Values: 'True' or 'False'
 ;                 True  -> send email with error report
 ;  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 informatino.
+;       preserve the maximum amount of historical log information.
 ;----------------------------------------------------------------------
-Report = False 
+SubFolderLimit = 10
+Report = False
 KeepLogCount = 10
 KeepLogDays = 30
 ;End of Settings
 in a specified location to be included in the backup.
 This behavior is indended to allow backups of the 
 clones to occur while leaving the original 
-repositories available for continued use.
+repositories available for continued use.
+
+The script has been written and compiled using AutoIt v3 
+scripting.  It is completely free, and the source code is 
+available at https://bitbucket.org/nedmech/hgprebackup/src.
+
+Usage
+-----
+This script has been compiled as a command-line application.
+Most backup utilities provide the option to call a pre-command
+before beginning the backup task.  This script is intended to 
+be used as the backup pre-command.  It can be run independently
+at any time as well.  Note that there are separate executables
+compiled for 32-bit (x86) and 64-bit (x64) operating systems.
+Make sure to reference the correct executable for the target
+operating system architecture.
+
+Command Line Syntax
+~~~~~~~~~~~~~~~~~~~
+The settings file is assumed to be the "HgPreBackupSettings.ini"
+file unless otherwise specified as an optional command-line argument.
+
+**NOTE:** If the path to the settings file contains spaces, it should be
+contained in double-quotation marks (") to ensure proper parsing.
+::
+
+> HgPreBackup.exe [settings file path]
+
+Example for 32-bit OS:
+::
+
+> HgPreBackup_x86.exe "HgPreBackupSettings_Project1.ini"
+
+Launching the executable directly from Windows Explorer
+(typically by double-clicking) will have the same effect
+as calling it from command-line with no optional arguments.
+The application will automatically run with settings in the
+"HgPreBackupSettings.ini" file, or the default settings if
+the settings file is not found.
+
+---------------------------------------------------------------------
+
+Configuration
+-------------
+The script behavior can be modified by changing the settings
+in the "HgPreBackupSettings.ini" file.  Additionally, the 
+settings file can be copied and renamed for different profiles,
+and the specific settings file for a profile may be specified
+as a command-line argument.
+
+[Path] Section
+~~~~~~~~~~~~~~
+* **hgPath** - Command path for the Mercurial application.  
+    This is typically just 'hg' if Mercurial has been installed 
+    such that the 'hg' command is recognised at the command line.  
+    If not, a full path to the Mercurial executable must be provided.
+    
+  - *Example*: ``hgPath = C:\Program Files\Mercurial\hg.exe``
+
+* **RepoPath** - Path to search for source repositories.  
+    All primary repositories found in the folder will be cloned to
+    the backup location.  Any subrepositories will only be cloned
+    as they are referenced by primary repositories.  The number of
+    layers of subfolders that will be checked is limited by the 
+    "SubFolderLimit" setting.
+    
+  - *Example*: ``RepoPath = C:\Repositories\Project1\``
+
+* **BackupPath** - Path where backup repositories are to be located.  
+    An exact mirror of the repositories (including subfolder paths)
+    found at "RepoPath" will be created and maintained at this 
+    location.  The Working Directory of the backup repositories will 
+    be kept at Revision 0000 (empty) in order to minimize the space 
+    required for a backup.  
+    
+  - *Example*: ``RepoPath = C:\BackupRepos\Project1\``
+
+* **LogPath** - Path where log files are to be created.  
+    Typically, this is the same as BackupPath, but an alternate path
+    may be specified to allow logs to be kept in a separate location.
+    
+  - *Example*: ``RepoPath = C:\BackupRepoLogs\Project1\``
+
+[Settings] Section
+~~~~~~~~~~~~~~~~~~
+* **SubFolderLimit** - Maxmum number of subfolders to check within RepoPath.
+    This allows the user to specify how deeply to scan the subfolders
+    of RepoPath for repositories.  The default value is ten (10).
+    A higher number will allow the script to find repositories that
+    may be more deeply nested.  A lower number will reduce the number
+    of subfolders that are scanned, potentially reducing the time it
+    takes to run the script.
+
+* **Report** - Send Email of log file if errors are encountered.
+
+  - Expected Values: 'True' or 'False'
+  
+    + True = Send Email with error report.
+    + False = No Email will be sent.
+  
+  - **NOTE:** When True, Email setting MUST be specified!!!
+
+* **KeepLogCount** - Keep at least this number of log files.
+
+  - 'KeepLogCount = 0' will keep no log files (KeepLogDays must also be 0)
+  - 'KeepLogCount = -1' will keep ALL log files (regardless of KeepLogDays setting)
+  
+* **KeepLogDays** - Keep at least this many days of log files. 
+
+  - 'KeepLogDays = 0' will keep no log files (KeepLogCount must also be 0)
+  - '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.
+
+[Email] Settings
+~~~~~~~~~~~~~~~~
+**NOTE:** All of the following MUST be specified if Report is True
+
+* **SMTPServer** - Name or IP of SMTP server to use. 
+
+  - *Example:* ``SMTPServer = smtp.gmail.com``
+  - **NOTE:** If using a *named* server instead of an IP address, 
+    make sure that the computer is able to resolve the name correctly.  
+    Verify the DNS settings or Hosts file can properly resolve the name.
+
+* **SMTPPort** - Port number to use for SMTP connection. 
+
+  - *Typical:* ``SMTPPort = 25``
+  - **NOTE:** GMail uses port 465
+
+* **SMTPssl** - Use Secure Socket Layer protocol or not. 
+
+  - ``SMTPssl = 0`` means no SSL is used (less secure, but 
+    required if the server does not support SSL)
+  - ``SMTPssl = 1`` means SSL is USED! (typically required
+    for servers with an "https" address, as well as GMail)
+
+* **SMTPUser** - Username for SMTP login.
+  
+  - This is often the same as the email address to be used 
+    for outgoing mail. 
+
+* **SMTPPassword** - Password for SMTP login.
+  
+  - **CAUTION!!!** - This setting is a known security issue!
+    The password is stored as plain text and is unencrypted.
+    Anyone with access to this file can gain access to the
+    associated SMTP Email account!  **USE AT YOUR OWN RISK!!!**
+    Keep this file in a safe and secure location.
+
+* **FromName** - Name to identify sender of Email
+  
+  - Can be left blank
+
+* **FromAddress** - Email address of sender.
+  
+  - *Typical format:* ``name@domain.com``
+
+* **ToAddress** - Comma separated list of addresses to send message to.
+
+---------------------------------------------------------------------
+
+Miscellaneous
+-------------
+
+Requirements
+~~~~~~~~~~~~
+* Windows� operating system 
+
+  - Developed on WinXP Professional v2002 x86 (SP3)
+  - Tested on Windows� Server 2008 x64 
+
+* Mercurial DVCS
+
+  - Developed using v2.01
+  - Earlier version may also be compatible, but not guaranteed.
+
+Dependencies
+~~~~~~~~~~~~
+* Microsoft� Script Runtime (scrrun.dll)
+
+  - Developed using Version 5.7.0.18066
+
+* Windows� NT BASE API Client DLL (kernel32.dll)
+
+  - Developed using Version 5.1.2600.5781
+
+* Microsoft� CDO for Windows� Library (cdosys.dll)
+
+  - Developed using Version 6.2.4.0
+
 				EndIf ;Check results of adding to the array.
 			EndIf ;Check for command error.
 		EndIf ;Check for existing backup repository.
-		;Update back to zero to clean out working directory for cleaner backups
+		;Update back to empty to clean out working directory for cleaner backups
 		_MercurialCommand( _
 			$HG_CMD_UPDATE & $HG_OPT_CLEAN & $HG_OPT_REPOSITORY, _
-			$sBackupPath, $HG_OPT_REVISION & ' 0')
+			$sBackupPath, $HG_OPT_REVISION & ' 0000')
 		#EndRegion - Backup Actions
 	Next ;$ii - loop through source repositories.
 	#Region - Evaluate Backup Repositories
 	$myResult = $myResult And FileWriteLine($hFile, "[settings]")
 	$myResult = $myResult And FileWriteLine($hFile, ";----------------------------------------------------------------------")
 	$myResult = $myResult And FileWriteLine($hFile, ";This section is where general preferences are specified.")
+	$myResult = $myResult And FileWriteLine($hFile, ";  SubFolderLimt .: Maxmum number of subfolders to check within RepoPath.")
 	$myResult = $myResult And FileWriteLine($hFile, ";  Report ..: Send email of log file if errors are encountered.")
 	$myResult = $myResult And FileWriteLine($hFile, ";             Expected Values: 'True' or 'False'")
 	$myResult = $myResult And FileWriteLine($hFile, ";                 True  -> send email with error report")
 	$myResult = $myResult And FileWriteLine($hFile, ";  NOTE - The KeepLog... settings work in combinaton with each other: ")
 	$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 informatino.")
+	$myResult = $myResult And FileWriteLine($hFile, ";       preserve the maximum amount of historical log information.")
 	$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)
 
 Func _ReadGlobalSettings( _
 		$IN_sSettingsFilePath)
+	Local $bValue, $iValue
 	#Region Read Path Items:
 	Local $sPath, $aTestPath, $szDrive, $szDir, $szFName, $szExt
 	;Read in Mercurial Path
 	$Gs_LogFileDir = _PathMake($szDrive, $szDir, $szFName, '')
 	#EndRegion Read Path Items
 	#Region Read Settings
-	Local $bValue = IniRead($IN_sSettingsFilePath, 'settings', 'Report', False)
+	$iValue = IniRead($IN_sSettingsFilePath, 'settings', 'SubFolderLimit', 10)
+	;Validate Setting Value
+	If (IsString($iValue) And _
+			StringIsDigit($iValue) Or StringIsFloat($iValue)) _
+	Or (IsNumber($iValue)) Then
+		$Gi_RecurseLimit = Number($iValue)
+	Else ;use default value
+		$Gi_RecurseLimit = 10
+	EndIf ;check for valid value in setting
+	$bValue = IniRead($IN_sSettingsFilePath, 'settings', 'Report', False)
 	;Validate Setting Value
 	If IsBool ($bValue) Then
 		$Gb_ReportErrors = $bValue
 	Else
 		$Gb_ReportErrors = False
 	EndIf
-	Local $iValue = IniRead($IN_sSettingsFilePath, 'settings', 'KeepLogCount', -1)
+	$iValue = IniRead($IN_sSettingsFilePath, 'settings', 'KeepLogCount', -1)
 	;Validate Setting Value
 	If (IsString($iValue) And _
 			StringIsDigit($iValue) Or StringIsFloat($iValue)) _
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.