Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
17bb2d8936 | ||
![]() |
a16ec85bad | ||
![]() |
a9a60214f8 | ||
![]() |
d11f88b4b1 | ||
![]() |
f378eeb3e6 |
12
README.md
12
README.md
@ -58,12 +58,22 @@ That's all. Snapcontrol will now be called by the Windows scheduler. See "snapco
|
||||
|
||||
```dos
|
||||
C:\>snapcontrol.exe /?
|
||||
usage: snapcontrol.exe [ /S | /I | /V> | /D | /? ]
|
||||
usage: snapcontrol.exe [ /S | /I | /V | /D | /? ]
|
||||
/S = silent mode (no user interaction!)
|
||||
/I = install/update scheduler job
|
||||
/V = show version
|
||||
/D = dry run
|
||||
/? = 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.
|
||||
|
BIN
snapcontrol.exe
BIN
snapcontrol.exe
Binary file not shown.
@ -1,12 +1,12 @@
|
||||
; SNAPCONTROL config file.
|
||||
; https://gitea.exabyte.systems/WINDOWS/snapcontrol
|
||||
; https://redbeard.ebslan.de/WINDOWS/snapcontrol.git
|
||||
;
|
||||
; This tool creates an image backups of windows machines,
|
||||
; it uses the Drive Snapshot tool by Tom Ehlert Software.
|
||||
; Please support this great tool and buy a license.
|
||||
; http://www.drivesnapshot.de/en/order.htm
|
||||
;
|
||||
; Copyright (c) 2019-2021 Michael H.G. Schmidt
|
||||
; Copyright (c) 2019-2024 Michael H.G. Schmidt
|
||||
; EMAIL: michael@schmidt2.de
|
||||
; Released under the MIT license.
|
||||
;
|
||||
@ -14,7 +14,8 @@
|
||||
;
|
||||
|
||||
[BACKUP]
|
||||
; path where snapshot.exe and cmail.exe is located ...
|
||||
; path where cmail.exe is located ...
|
||||
; (snaphot64.exe, this inifile and snapcontrol.exe must be always located in %WINDIR%!)
|
||||
BinPath = c:\tools
|
||||
|
||||
; target PATH examples:
|
||||
|
@ -7,7 +7,7 @@
|
||||
; LICENSE : MIT License
|
||||
; AUTHOR : Michael H.G. Schmidt
|
||||
; EMAIL : michael@schmidt2.de
|
||||
; DATE : 20230319
|
||||
; DATE : 20240222
|
||||
; ------------------------------------------------------------
|
||||
;
|
||||
; 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.13"
|
||||
Global updatesched = 0
|
||||
Global dryrun = 0
|
||||
Global silentmode = 0
|
||||
@ -38,20 +38,19 @@ 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"
|
||||
|
||||
; valid versions for Drive Snapshot we support ...
|
||||
NewList DriveSnapshotVersion$()
|
||||
AddElement(DriveSnapshotVersion$())
|
||||
DriveSnapshotVersion$() = "V1.46"
|
||||
|
||||
For i = 46 To 55
|
||||
AddElement(DriveSnapshotVersion$())
|
||||
DriveSnapshotVersion$() = "V1.47"
|
||||
|
||||
AddElement(DriveSnapshotVersion$())
|
||||
DriveSnapshotVersion$() = "V1.48"
|
||||
DriveSnapshotVersion$() = "V1." + Str(i)
|
||||
Next
|
||||
|
||||
Procedure Usage()
|
||||
PrintN ("usage: snapcontrol.exe [ /S | /I | /V | /D | /? ]")
|
||||
@ -60,6 +59,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
|
||||
|
||||
@ -138,15 +147,15 @@ Global MailPass$ = Trim(ReadPreferenceString("MailPass",""))
|
||||
; which Drive Snapshot version should be used ?
|
||||
arch$ = GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")
|
||||
If ( arch$ = "x86" )
|
||||
SnapshotBin$ = BinPath$ + "\snapshot.exe"
|
||||
SnapshotBin$ = "c:\windows\snapshot.exe"
|
||||
Else
|
||||
SnapshotBin$ = BinPath$ + "\snapshot64.exe"
|
||||
SnapshotBin$ = "c:\windows\snapshot64.exe"
|
||||
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 +163,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 +188,7 @@ If ( DriveSnapshotVersionOk = 0 )
|
||||
ForEach DriveSnapshotVersion$()
|
||||
PrintN(" - " + DriveSnapshotVersion$())
|
||||
Next
|
||||
End 1
|
||||
End 95
|
||||
EndIf
|
||||
|
||||
;
|
||||
@ -250,7 +259,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 +410,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 +476,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 +521,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 +558,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 = 49
|
||||
; FirstLine = 22
|
||||
; Folding = --
|
||||
; EnableXP
|
||||
; Executable = snapcontrol.exe
|
||||
|
Loading…
Reference in New Issue
Block a user