bugfix: snapcontrol says SUCCESS after NTCOPY error.
This commit is contained in:
parent
fe2a4e0a9b
commit
f378eeb3e6
BIN
snapcontrol.exe
BIN
snapcontrol.exe
Binary file not shown.
@ -7,7 +7,7 @@
|
||||
; LICENSE : MIT License
|
||||
; AUTHOR : Michael H.G. Schmidt
|
||||
; EMAIL : michael@schmidt2.de
|
||||
; DATE : 20230319
|
||||
; DATE : 20230723
|
||||
; ------------------------------------------------------------
|
||||
;
|
||||
; This tool creates an image backups of windows machines,
|
||||
@ -28,7 +28,7 @@ EnableGraphicalConsole(0)
|
||||
|
||||
Dim filelist$(0)
|
||||
|
||||
Global VERSION$="V1.11"
|
||||
Global VERSION$="V1.12"
|
||||
Global updatesched = 0
|
||||
Global dryrun = 0
|
||||
Global silentmode = 0
|
||||
@ -38,6 +38,8 @@ Global month$ = FormatDate("%mm", Date())
|
||||
Global day$ = FormatDate("%dd", Date())
|
||||
Global DriveSnapshotVersionOk = 0
|
||||
Global DoShutdown = 0
|
||||
Global RC = 0 ; returncode
|
||||
Global RC_ALL = 0 ; cumulated returncode
|
||||
|
||||
; Timeout for shutodwn is 2 minutes ...
|
||||
Global Shutdowncommand$ = "shutdown /s /t 120 /d p:0:0"
|
||||
@ -60,6 +62,16 @@ Procedure Usage()
|
||||
PrintN (" /V = show version")
|
||||
PrintN (" /D = dry run")
|
||||
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
|
||||
EndProcedure
|
||||
|
||||
@ -146,7 +158,7 @@ EndIf
|
||||
; Drive Snapshot found ?
|
||||
If ( FileSize ( SnapshotBin$ ) < 0 )
|
||||
PrintN("ERROR: [ " + SnapshotBin$ + " ] NOT found.")
|
||||
End 1
|
||||
End 94
|
||||
EndIf
|
||||
|
||||
Global MailCommand$ = BinPath$ + "\cmail.exe"
|
||||
@ -154,7 +166,7 @@ Global MailCommand$ = BinPath$ + "\cmail.exe"
|
||||
; CMail found ?
|
||||
If ( FileSize ( MailCommand$ ) < 0 And MailReport$ = "yes")
|
||||
PrintN("ERROR: [ " + MailCommand$ + " ] NOT found.")
|
||||
End 1
|
||||
End 96
|
||||
EndIf
|
||||
|
||||
; Version check for Drive Snapshot ...
|
||||
@ -179,7 +191,7 @@ If ( DriveSnapshotVersionOk = 0 )
|
||||
ForEach DriveSnapshotVersion$()
|
||||
PrintN(" - " + DriveSnapshotVersion$())
|
||||
Next
|
||||
End 1
|
||||
End 95
|
||||
EndIf
|
||||
|
||||
;
|
||||
@ -250,7 +262,6 @@ Procedure EndProg(err)
|
||||
Else
|
||||
LogMe("ERROR: END of BACKUP with result FAILED !")
|
||||
s$ = "BACKUP report - { ERROR ! } @" + hostname$
|
||||
|
||||
EndIf
|
||||
|
||||
; send a report via mail ?
|
||||
@ -402,8 +413,8 @@ If ( dryrun = 1 )
|
||||
LogMe("DRYRUN - (simulating a backup run) !!!")
|
||||
EndIf
|
||||
|
||||
e = IsAdmin()
|
||||
If ( e = 0 )
|
||||
RC = IsAdmin()
|
||||
If ( RC = 0 )
|
||||
LogMe("OK. Running as Admin ...")
|
||||
Else
|
||||
PrintN("ERROR: Please run as Administrator !")
|
||||
@ -468,7 +479,7 @@ If ( FtpBackup$ = "yes" )
|
||||
LogMe("INFO: FTP backup, using server [ " + FtpServer$ + " ] for backup ...")
|
||||
|
||||
; add ftp account ...
|
||||
e = system(SnapshotBin$ + " --AddFTPAccount:" + TargetUser$ + "," + FtpServer$ + "," + TargetPassword$)
|
||||
RC = system(SnapshotBin$ + " --AddFTPAccount:" + TargetUser$ + "," + FtpServer$ + "," + TargetPassword$)
|
||||
|
||||
; generate filenames for backup ...
|
||||
DumpFile$ = TargetPath$ + "/" + hostname$ + "_snapshot_" + month$ + "_$type_$disk.sna"
|
||||
@ -513,11 +524,11 @@ Else
|
||||
FinishDirectory(0)
|
||||
EndIf
|
||||
|
||||
e = 0
|
||||
; do a quickcheck ...
|
||||
For i = 1 To ArraySize(filelist$())
|
||||
LogMe("INFO: Starting QUICKCHECK for [ " + filelist$(i-1) + " ]")
|
||||
e = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " --QuickCheck:" + TargetPath$ + "\" + filelist$(i-1))
|
||||
If ( e <> 0 )
|
||||
RC = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " --QuickCheck:" + TargetPath$ + "\" + filelist$(i-1))
|
||||
If ( RC <> 0 )
|
||||
LogMe("ERROR: DELETING last full backup [ REASON: corrupt file! ]")
|
||||
dummy = system("del /F /Q " + TargetPath$ + "\" + hostname$ + "_snapshot_" + month$ + "_ful*.*")
|
||||
Break
|
||||
@ -550,23 +561,36 @@ EndIf
|
||||
LogMe(" HashFile: [ " + Mid(HashFile$,3) + " ]")
|
||||
LogMe(" LogFile: [ " + LogFile$ + " ]")
|
||||
|
||||
; execute snapshot64 ...
|
||||
If ( dryrun = 0 )
|
||||
e = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " " + params$ + " " + DumpFile$ + " " + HashFile$)
|
||||
|
||||
RC = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " " + params$ + " " + DumpFile$ + " " + HashFile$)
|
||||
RC_ALL = RC_ALL + RC
|
||||
|
||||
If ( RC > 0 )
|
||||
LogMe("ERROR: while executing [ " + SnapshotBin$ + " ]!")
|
||||
EndIf
|
||||
|
||||
If DoShutdown = 1
|
||||
LogMe("INFO: shutdown was requested ...")
|
||||
LogMe("INFO: executing [ " + ShutdownCommand$ + " ]")
|
||||
e = system(ShutdownCommand$)
|
||||
RC = system(ShutdownCommand$)
|
||||
RC_ALL = RC_ALL + RC
|
||||
|
||||
If ( RC > 0 )
|
||||
LogMe("ERROR: while executing shutdown command!")
|
||||
EndIf
|
||||
|
||||
EndIf
|
||||
|
||||
EndIf
|
||||
|
||||
; end with return code...
|
||||
EndProg(e)
|
||||
EndProg(RC_ALL)
|
||||
|
||||
; IDE Options = PureBasic 5.73 LTS (Windows - x64)
|
||||
; ExecutableFormat = Console
|
||||
; CursorPosition = 20
|
||||
; CursorPosition = 44
|
||||
; FirstLine = 41
|
||||
; Folding = --
|
||||
; EnableXP
|
||||
; Executable = snapcontrol.exe
|
||||
|
Loading…
Reference in New Issue
Block a user