Compare commits

..

No commits in common. "master" and "V1.11" have entirely different histories.

4 changed files with 30 additions and 62 deletions

View File

@ -58,22 +58,12 @@ That's all. Snapcontrol will now be called by the Windows scheduler. See "snapco
```dos ```dos
C:\>snapcontrol.exe /? C:\>snapcontrol.exe /?
usage: snapcontrol.exe [ /S | /I | /V | /D | /? ] usage: snapcontrol.exe [ /S | /I | /V> | /D | /? ]
/S = silent mode (no user interaction!) /S = silent mode (no user interaction!)
/I = install/update scheduler job /I = install/update scheduler job
/V = show version /V = show version
/D = dry run /D = dry run
/? = help /? = help
RETURNCODES:
-----------------------------------------------------
99 = usage was called / wrong arguments or parameters
98 = cannot read inifile (does not exist ?)
97 = i don't have admin rights
96 = mailer (cmail) not found or not working
95 = Drive Snapshot version is not supported
94 = Drive Snapshot exe not found
0 = OK
``` ```
*HINT:* Everytime you change the values in "BackupSched" or "BackupStart" you will have to call snapcontrol.exe with the /I switch. *HINT:* Everytime you change the values in "BackupSched" or "BackupStart" you will have to call snapcontrol.exe with the /I switch.

Binary file not shown.

View File

@ -1,12 +1,12 @@
; SNAPCONTROL config file. ; SNAPCONTROL config file.
; https://redbeard.ebslan.de/WINDOWS/snapcontrol.git ; https://gitea.exabyte.systems/WINDOWS/snapcontrol
; ;
; This tool creates an image backups of windows machines, ; This tool creates an image backups of windows machines,
; it uses the Drive Snapshot tool by Tom Ehlert Software. ; it uses the Drive Snapshot tool by Tom Ehlert Software.
; Please support this great tool and buy a license. ; Please support this great tool and buy a license.
; http://www.drivesnapshot.de/en/order.htm ; http://www.drivesnapshot.de/en/order.htm
; ;
; Copyright (c) 2019-2024 Michael H.G. Schmidt ; Copyright (c) 2019-2021 Michael H.G. Schmidt
; EMAIL: michael@schmidt2.de ; EMAIL: michael@schmidt2.de
; Released under the MIT license. ; Released under the MIT license.
; ;
@ -14,8 +14,7 @@
; ;
[BACKUP] [BACKUP]
; path where cmail.exe is located ... ; path where snapshot.exe and cmail.exe is located ...
; (snaphot64.exe, this inifile and snapcontrol.exe must be always located in %WINDIR%!)
BinPath = c:\tools BinPath = c:\tools
; target PATH examples: ; target PATH examples:

View File

@ -7,7 +7,7 @@
; LICENSE : MIT License ; LICENSE : MIT License
; AUTHOR : Michael H.G. Schmidt ; AUTHOR : Michael H.G. Schmidt
; EMAIL : michael@schmidt2.de ; EMAIL : michael@schmidt2.de
; DATE : 20240222 ; DATE : 20230319
; ------------------------------------------------------------ ; ------------------------------------------------------------
; ;
; This tool creates an image backups of windows machines, ; This tool creates an image backups of windows machines,
@ -28,7 +28,7 @@ EnableGraphicalConsole(0)
Dim filelist$(0) Dim filelist$(0)
Global VERSION$="V1.13" Global VERSION$="V1.11"
Global updatesched = 0 Global updatesched = 0
Global dryrun = 0 Global dryrun = 0
Global silentmode = 0 Global silentmode = 0
@ -38,19 +38,20 @@ Global month$ = FormatDate("%mm", Date())
Global day$ = FormatDate("%dd", Date()) Global day$ = FormatDate("%dd", Date())
Global DriveSnapshotVersionOk = 0 Global DriveSnapshotVersionOk = 0
Global DoShutdown = 0 Global DoShutdown = 0
Global RC = 0 ; returncode
Global RC_ALL = 0 ; cumulated returncode
; Timeout for shutodwn is 2 minutes ... ; Timeout for shutodwn is 2 minutes ...
Global Shutdowncommand$ = "shutdown /s /t 120 /d p:0:0" Global Shutdowncommand$ = "shutdown /s /t 120 /d p:0:0"
; valid versions for Drive Snapshot we support ... ; valid versions for Drive Snapshot we support ...
NewList DriveSnapshotVersion$() NewList DriveSnapshotVersion$()
For i = 46 To 55
AddElement(DriveSnapshotVersion$()) AddElement(DriveSnapshotVersion$())
DriveSnapshotVersion$() = "V1." + Str(i) DriveSnapshotVersion$() = "V1.46"
Next
AddElement(DriveSnapshotVersion$())
DriveSnapshotVersion$() = "V1.47"
AddElement(DriveSnapshotVersion$())
DriveSnapshotVersion$() = "V1.48"
Procedure Usage() Procedure Usage()
PrintN ("usage: snapcontrol.exe [ /S | /I | /V | /D | /? ]") PrintN ("usage: snapcontrol.exe [ /S | /I | /V | /D | /? ]")
@ -59,16 +60,6 @@ Procedure Usage()
PrintN (" /V = show version") PrintN (" /V = show version")
PrintN (" /D = dry run") PrintN (" /D = dry run")
PrintN (" /? = help") PrintN (" /? = help")
PrintN ("")
PrintN ("RETURNCODES:")
PrintN ("-----------------------------------------------------")
PrintN ("99 = usage was called / wrong arguments or parameters")
PrintN ("98 = cannot read inifile (does not exist ?)")
PrintN ("97 = i don't have admin rights")
PrintN ("96 = mailer (cmail) not found or not working")
PrintN ("95 = Drive Snapshot version is not supported")
PrintN ("94 = Drive Snapshot exe not found")
PrintN (" 0 = OK")
End 99 End 99
EndProcedure EndProcedure
@ -147,15 +138,15 @@ Global MailPass$ = Trim(ReadPreferenceString("MailPass",""))
; which Drive Snapshot version should be used ? ; which Drive Snapshot version should be used ?
arch$ = GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") arch$ = GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")
If ( arch$ = "x86" ) If ( arch$ = "x86" )
SnapshotBin$ = "c:\windows\snapshot.exe" SnapshotBin$ = BinPath$ + "\snapshot.exe"
Else Else
SnapshotBin$ = "c:\windows\snapshot64.exe" SnapshotBin$ = BinPath$ + "\snapshot64.exe"
EndIf EndIf
; Drive Snapshot found ? ; Drive Snapshot found ?
If ( FileSize ( SnapshotBin$ ) < 0 ) If ( FileSize ( SnapshotBin$ ) < 0 )
PrintN("ERROR: [ " + SnapshotBin$ + " ] NOT found.") PrintN("ERROR: [ " + SnapshotBin$ + " ] NOT found.")
End 94 End 1
EndIf EndIf
Global MailCommand$ = BinPath$ + "\cmail.exe" Global MailCommand$ = BinPath$ + "\cmail.exe"
@ -163,7 +154,7 @@ Global MailCommand$ = BinPath$ + "\cmail.exe"
; CMail found ? ; CMail found ?
If ( FileSize ( MailCommand$ ) < 0 And MailReport$ = "yes") If ( FileSize ( MailCommand$ ) < 0 And MailReport$ = "yes")
PrintN("ERROR: [ " + MailCommand$ + " ] NOT found.") PrintN("ERROR: [ " + MailCommand$ + " ] NOT found.")
End 96 End 1
EndIf EndIf
; Version check for Drive Snapshot ... ; Version check for Drive Snapshot ...
@ -188,7 +179,7 @@ If ( DriveSnapshotVersionOk = 0 )
ForEach DriveSnapshotVersion$() ForEach DriveSnapshotVersion$()
PrintN(" - " + DriveSnapshotVersion$()) PrintN(" - " + DriveSnapshotVersion$())
Next Next
End 95 End 1
EndIf EndIf
; ;
@ -259,6 +250,7 @@ Procedure EndProg(err)
Else Else
LogMe("ERROR: END of BACKUP with result FAILED !") LogMe("ERROR: END of BACKUP with result FAILED !")
s$ = "BACKUP report - { ERROR ! } @" + hostname$ s$ = "BACKUP report - { ERROR ! } @" + hostname$
EndIf EndIf
; send a report via mail ? ; send a report via mail ?
@ -410,8 +402,8 @@ If ( dryrun = 1 )
LogMe("DRYRUN - (simulating a backup run) !!!") LogMe("DRYRUN - (simulating a backup run) !!!")
EndIf EndIf
RC = IsAdmin() e = IsAdmin()
If ( RC = 0 ) If ( e = 0 )
LogMe("OK. Running as Admin ...") LogMe("OK. Running as Admin ...")
Else Else
PrintN("ERROR: Please run as Administrator !") PrintN("ERROR: Please run as Administrator !")
@ -476,7 +468,7 @@ If ( FtpBackup$ = "yes" )
LogMe("INFO: FTP backup, using server [ " + FtpServer$ + " ] for backup ...") LogMe("INFO: FTP backup, using server [ " + FtpServer$ + " ] for backup ...")
; add ftp account ... ; add ftp account ...
RC = system(SnapshotBin$ + " --AddFTPAccount:" + TargetUser$ + "," + FtpServer$ + "," + TargetPassword$) e = system(SnapshotBin$ + " --AddFTPAccount:" + TargetUser$ + "," + FtpServer$ + "," + TargetPassword$)
; generate filenames for backup ... ; generate filenames for backup ...
DumpFile$ = TargetPath$ + "/" + hostname$ + "_snapshot_" + month$ + "_$type_$disk.sna" DumpFile$ = TargetPath$ + "/" + hostname$ + "_snapshot_" + month$ + "_$type_$disk.sna"
@ -521,11 +513,11 @@ Else
FinishDirectory(0) FinishDirectory(0)
EndIf EndIf
; do a quickcheck ... e = 0
For i = 1 To ArraySize(filelist$()) For i = 1 To ArraySize(filelist$())
LogMe("INFO: Starting QUICKCHECK for [ " + filelist$(i-1) + " ]") LogMe("INFO: Starting QUICKCHECK for [ " + filelist$(i-1) + " ]")
RC = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " --QuickCheck:" + TargetPath$ + "\" + filelist$(i-1)) e = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " --QuickCheck:" + TargetPath$ + "\" + filelist$(i-1))
If ( RC <> 0 ) If ( e <> 0 )
LogMe("ERROR: DELETING last full backup [ REASON: corrupt file! ]") LogMe("ERROR: DELETING last full backup [ REASON: corrupt file! ]")
dummy = system("del /F /Q " + TargetPath$ + "\" + hostname$ + "_snapshot_" + month$ + "_ful*.*") dummy = system("del /F /Q " + TargetPath$ + "\" + hostname$ + "_snapshot_" + month$ + "_ful*.*")
Break Break
@ -558,36 +550,23 @@ EndIf
LogMe(" HashFile: [ " + Mid(HashFile$,3) + " ]") LogMe(" HashFile: [ " + Mid(HashFile$,3) + " ]")
LogMe(" LogFile: [ " + LogFile$ + " ]") LogMe(" LogFile: [ " + LogFile$ + " ]")
; execute snapshot64 ...
If ( dryrun = 0 ) If ( dryrun = 0 )
RC = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " " + params$ + " " + DumpFile$ + " " + HashFile$) e = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " " + params$ + " " + DumpFile$ + " " + HashFile$)
RC_ALL = RC_ALL + RC
If ( RC > 0 )
LogMe("ERROR: while executing [ " + SnapshotBin$ + " ]!")
EndIf
If DoShutdown = 1 If DoShutdown = 1
LogMe("INFO: shutdown was requested ...") LogMe("INFO: shutdown was requested ...")
LogMe("INFO: executing [ " + ShutdownCommand$ + " ]") LogMe("INFO: executing [ " + ShutdownCommand$ + " ]")
RC = system(ShutdownCommand$) e = system(ShutdownCommand$)
RC_ALL = RC_ALL + RC
If ( RC > 0 )
LogMe("ERROR: while executing shutdown command!")
EndIf
EndIf EndIf
EndIf EndIf
; end with return code... ; end with return code...
EndProg(RC_ALL) EndProg(e)
; IDE Options = PureBasic 5.73 LTS (Windows - x64) ; IDE Options = PureBasic 5.73 LTS (Windows - x64)
; ExecutableFormat = Console ; ExecutableFormat = Console
; CursorPosition = 49 ; CursorPosition = 20
; FirstLine = 22
; Folding = -- ; Folding = --
; EnableXP ; EnableXP
; Executable = snapcontrol.exe ; Executable = snapcontrol.exe