diff --git a/README.md b/README.md index 0ec5832..8238c1d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Get it from here: https://www.inveigle.net/cmail/download ## Installation -- Download the latest release and unzip the files +- Download the latest release and unzip the files (.exe and .ini file) to some path of your choice - Open "snapcontrol.ini" with the editor of your choice and set the following variables: - BinPath - TargetPath @@ -49,21 +49,21 @@ Get it from here: https://www.inveigle.net/cmail/download snapcontrol.exe /I ``` -( Snapcontrol copies the config file and itself to the location of the "InstallTo" variable. ) +Snapcontrol will find "snapcontrol.ini" automagically in the path where snapcontrol.exe was *installed*! -That's all. Snapcontrol will be called by the Windows scheduler. See "snapcontrol.ini" for detailed comments on the features. +That's all. Snapcontrol will now be called by the Windows scheduler. See "snapcontrol.ini" for detailed comments on the features. ## USAGE ```dos C:\>snapcontrol.exe /? -usage: snapcontrol.exe - /I = install program and config - /U = update scheduler job - /D = dry run +usage: snapcontrol.exe [ /I | /V> | /D | /? ] + /I = install/update scheduler job /V = show version + /D = dry run + /? = help ``` -Everytime you change the values in "BackupSched" or "BackupStart" you will have to call snapcontrol.exe with the /U switch. +Everytime you change the values in "BackupSched" or "BackupStart" you will have to call snapcontrol.exe with the /I switch. diff --git a/snapcontrol.exe b/snapcontrol.exe index 6374990..bfd4655 100644 Binary files a/snapcontrol.exe and b/snapcontrol.exe differ diff --git a/snapcontrol.ini b/snapcontrol.ini index 884d3a9..e7e3f00 100644 --- a/snapcontrol.ini +++ b/snapcontrol.ini @@ -1,5 +1,5 @@ ; SNAPCONTROL config file. -; https://github.com/mhgschmidt/snapcontrol +; https://gitea.exabyte.systems/WINDOWS/snapcontrol ; ; This tool creates an image backups of windows machines, ; it uses the Drive Snapshot tool by Tom Ehlert Software. @@ -13,16 +13,10 @@ ; IMPORTANT: DO NOT USE quotation marks in this INIFILE ! ; - -[INSTALL] -; where to install the exe and the infile ... -InstallTo = c:\snapshot - +[BACKUP] ; path where snapshot.exe and cmail.exe is located ... BinPath = c:\tools - -[BACKUP] ; target PATH examples: ; - "D:\BACKUP" (LOCAL path on drive d:) ; - "\\example\share" (SMB share on server "example") @@ -88,8 +82,15 @@ AskForShutdown = yes [LOGGING] -LogFile = backup.log -HistLog = history.log + +; directory for logfiles +LogDir = C: + +; single run logfile +LogFile = snapshot-backup.log + +; cumulated logfile +HistLog = snapshot-history.log [MAIL] diff --git a/snapcontrol.pb b/snapcontrol.pb index 3428e07..7b738ba 100644 --- a/snapcontrol.pb +++ b/snapcontrol.pb @@ -7,7 +7,7 @@ ; LICENSE : MIT License ; AUTHOR : Michael H.G. Schmidt ; EMAIL : michael@schmidt2.de -; DATE : 20211021 +; DATE : 20230311 ; ------------------------------------------------------------ ; ; This tool creates an image backups of windows machines, @@ -29,8 +29,7 @@ EnableGraphicalConsole(0) Dim filelist$(0) -Global VERSION$="V1.07b" -Global installme = 0 +Global VERSION$="V1.08" Global updatesched = 0 Global dryrun = 0 Global hostname$ = GetEnvironmentVariable("COMPUTERNAME") @@ -53,36 +52,34 @@ NewList DriveSnapshotVersion$() DriveSnapshotVersion$() = "V1.48" Procedure Usage() - PrintN ("usage: snapcontrol.exe ") - PrintN (" /I = install program and config") - PrintN (" /U = update scheduler job") - PrintN (" /D = dry run") + PrintN ("usage: snapcontrol.exe [ /I | /V> | /D | /? ]") + PrintN (" /I = install/update scheduler job") PrintN (" /V = show version") + PrintN (" /D = dry run") + PrintN (" /? = help") End 99 EndProcedure ; check commandline... -If ( CountProgramParameters() >1 ) +If ( CountProgramParameters() > 1 ) Usage() EndIf -; set path for inifile ... -inifile$ = RTrim(GetPathPart(ProgramFilename()),"\") + "\snapcontrol.ini" - -; install job, update job, show version, dry run ... +; install or update job, show version, dry run ... If ( UCase(ProgramParameter(0)) = "/I" ) - installme = 1 -ElseIf ( UCase(ProgramParameter(0)) = "/U" ) updatesched = 1 ElseIf ( UCase(ProgramParameter(0)) = "/V" ) PrintN ("Version = " + VERSION$) End 0 ElseIf ( UCase(ProgramParameter(0)) = "/D" ) dryrun = 1 -ElseIf ( UCase(ProgramParameter(0)) = "/?" ) - Usage() +ElseIf ( ProgramParameter(0) = "/?" ) + Usage() EndIf +; set path for inifile ... +inifile$ = RTrim(GetPathPart(ProgramFilename()),"\") + "\snapcontrol.ini" + ; Procedure "RunProgram" aborts after writing approx. 8GB data with snapshot64... ; so we will use native "system" command... ImportC "msvcrt.lib" @@ -94,11 +91,8 @@ If (Not OpenPreferences(inifile$)) End 98 EndIf -PreferenceGroup("install") -Global InstallTo$ = Trim(ReadPreferenceString("InstallTo","c:\snapshot")) -Global BinPath$ = Trim(ReadPreferenceString("BinPath","c:\tools")) - PreferenceGroup("backup") +Global BinPath$ = Trim(ReadPreferenceString("BinPath","c:\tools")) Global TargetPath$ = Trim(ReadPreferenceString("TargetPath","\\server\share")) Global FtpBackup$ = Trim(ReadPreferenceString("FtpBackup","no")) Global FtpServer$ = Trim(LCase(ReadPreferenceString("FtpServer","none"))) @@ -118,12 +112,13 @@ Global EjectMedia$ = Trim(LCase(ReadPreferenceString("EjectMedia","yes"))) Global AskForShutdown$ = Trim(LCase(ReadPreferenceString("AskForShutdown","no"))) PreferenceGroup("logging") -Global LogFile$ = Trim(ReadPreferenceString("LogFile","backup.log")) -Global HistLog$ = Trim(ReadPreferenceString("HistLog","history.log")) +Global LogDir$ = Trim(ReadPreferenceString("LogDir","C:")) +Global LogFile$ = Trim(ReadPreferenceString("LogFile","snapshot-backup.log")) +Global HistLog$ = Trim(ReadPreferenceString("HistoryLog","snapshot-history.log")) ; add PATH to logfiles ... -LogFile$ = InstallTo$ + "\" + LogFile$ -HistLog$ = InstallTo$ + "\" + HistLog$ +LogFile$ = LogDir$ + "\" + LogFile$ +HistLog$ = LogDir$ + "\" + HistLog$ PreferenceGroup("mail") Global MailReport$ = Trim(LCase(ReadPreferenceString("MailReport","no"))) @@ -306,33 +301,7 @@ EndProcedure ; MAIN ; -; installation requested ? -If ( installme = 1 ) - - ; delete old logfiles ... - LogMe("INFO: deleting old logfiles ...") - dummy = system("del /F /Q " + LogFile$ + " 2>nul") - dummy = system("del /F /Q " + HistLog$ + " 2>nul") - - ; create directory ... - LogMe("INFO: creating directory [ " + InstallTo$ + " ] ...") - dummy = system("mkdir " + InstallTo$ + " >nul 2>&1") - - ; copy binary and inifile ... - LogMe("INFO: copy binary and inifile to folder [ " + InstallTo$ + " ] ...") - dummy = system("copy /Y " + inifile$ + " " + InstallTo$ + " 2>nul") - dummy = system("copy /Y " + ProgramFilename() + " " + InstallTo$ + " 2>nul") - - ; update jobscheduler (selfcall) ... - dummy = system(InstallTo$ + "\snapcontrol.exe /U 2>nul") - - ClosePreferences() - CloseConsole() - End - -EndIf - -; update for jobscheduler requested ? +; install or update for jobscheduler requested ? If ( updatesched = 1 ) username$ = GetEnvironmentVariable("USERNAME") @@ -344,7 +313,7 @@ If ( updatesched = 1 ) PrintN("WARNING: unknown BackupschedMode [ " + BackupschedMode$ + " ] ---> IGNORING. Type will be set to LOGIN.") BackupschedMode$ = "LOGIN" EndIf - + ; update the job ... PrintN ("Updating windows jobscheduler ...") If ( BackupschedMode$ = "time" ) @@ -403,6 +372,7 @@ dummy = DeleteFile(LogFile$, #PB_FileSystem_Force) LogMe("============== starting BACKUP ==============") LogMe("snapcontrol.exe version = [ " + VERSION$ + " ]") LogMe(" snapshot.exe version = [ " + DriveSnapshotVersion$() + " ]") +LogMe(" INIFILE = [ " + inifile$ + " ]") If ( dryrun = 1 ) LogMe("DRYRUN - (simulating a backup run) !!!") @@ -438,7 +408,7 @@ If ( Encrypt$ = "dynamic" ) LogMe("WARNING: ENCRYPTED backup requested and DYNAMIC password was requested !") LogMeRaw(" Generated password is: --->>> " + EncryptPW$ + " <<<---") LogMe("INFO: writing password to inifile...") - PreferenceGroup("Global") + PreferenceGroup("backup") dummy = WritePreferenceString("EncryptPW", EncryptPW$) Else LogMe("WARNING: ENCRYPTED backup requested. Using DYNAMIC password in inifile !") @@ -572,8 +542,7 @@ EndProg(e) ; IDE Options = PureBasic 5.73 LTS (Windows - x64) ; ExecutableFormat = Console -; CursorPosition = 555 -; FirstLine = 519 +; CursorPosition = 31 ; Folding = -- ; EnableXP ; Executable = snapcontrol.exe