added shutdown after backup feature
This commit is contained in:
parent
65dd48b54a
commit
9b940563b1
BIN
snapcontrol.exe
BIN
snapcontrol.exe
Binary file not shown.
@ -83,6 +83,9 @@ LimitIO =
|
||||
; should drive/media be ejected after backup ? (yes/no)
|
||||
EjectMedia = yes
|
||||
|
||||
; should we ask for a shutdown after backup ? (yes/no)
|
||||
AskForShutdown = yes
|
||||
|
||||
|
||||
[LOGGING]
|
||||
LogFile = backup.log
|
||||
|
@ -29,7 +29,7 @@ EnableGraphicalConsole(0)
|
||||
|
||||
Dim filelist$(0)
|
||||
|
||||
Global VERSION$="V1.03"
|
||||
Global VERSION$="V1.04"
|
||||
Global installme = 0
|
||||
Global updatesched = 0
|
||||
Global dryrun = 0
|
||||
@ -38,6 +38,8 @@ Global jobname$ = "snapcontrol"
|
||||
Global month$ = FormatDate("%mm", Date())
|
||||
Global day$ = FormatDate("%dd", Date())
|
||||
Global DriveSnapshotVersionOk = 0
|
||||
Global DoShutdown = 0
|
||||
Global Shutdowncommand$ = "shutdown /s /f"
|
||||
|
||||
; valid versions for Drive Snapshot we support ...
|
||||
NewList DriveSnapshotVersion$()
|
||||
@ -99,20 +101,21 @@ Global BinPath$ = ReadPreferenceString("BinPath","c:\tools")
|
||||
PreferenceGroup("backup")
|
||||
Global TargetPath$ = ReadPreferenceString("TargetPath","\\server\share")
|
||||
Global FtpBackup$ = ReadPreferenceString("FtpBackup","no")
|
||||
Global FtpServer$ = ReadPreferenceString("FtpServer","none")
|
||||
Global FtpServer$ = LCase(ReadPreferenceString("FtpServer","none"))
|
||||
Global TargetUser$ = ReadPreferenceString("TargetUser","guest")
|
||||
Global TargetPassword$ = ReadPreferenceString("TargetPassword","guest")
|
||||
Global BackupschedMode$ = ReadPreferenceString("BackupschedMode","LOGIN")
|
||||
Global BackupschedMode$ = LCase(ReadPreferenceString("BackupschedMode","login"))
|
||||
Global BackupStart$ = ReadPreferenceString("BackupStart","0005:00")
|
||||
Global Disks2Dump$ = ReadPreferenceString("Disks2Dump","HD1:*")
|
||||
Global ExcludeList$ = ReadPreferenceString("ExcludeList","")
|
||||
Global DumpSize$ = ReadPreferenceString("DumpSize","4095")
|
||||
Global Verify$ = ReadPreferenceString("Verify","yes")
|
||||
Global BurnTrash$ = ReadPreferenceString("BurnTrash","no")
|
||||
Global Encrypt$ = ReadPreferenceString("Encrypt","no")
|
||||
Global Verify$ = LCase(ReadPreferenceString("Verify","yes"))
|
||||
Global BurnTrash$ = LCase(ReadPreferenceString("BurnTrash","no"))
|
||||
Global Encrypt$ = LCase(ReadPreferenceString("Encrypt","no"))
|
||||
Global EncryptPW$ = ReadPreferenceString("EncryptPW","")
|
||||
Global LimitIO$ = ReadPreferenceString("LimitIO","")
|
||||
Global EjectMedia$ = ReadPreferenceString("EjectMedia","yes")
|
||||
Global EjectMedia$ = LCase(ReadPreferenceString("EjectMedia","yes"))
|
||||
Global AskForShutdown$ = LCase(ReadPreferenceString("AskForShutdown","no"))
|
||||
|
||||
PreferenceGroup("logging")
|
||||
Global LogFile$ = ReadPreferenceString("LogFile","backup.log")
|
||||
@ -123,7 +126,7 @@ LogFile$ = InstallTo$ + "\" + LogFile$
|
||||
HistLog$ = InstallTo$ + "\" + HistLog$
|
||||
|
||||
PreferenceGroup("mail")
|
||||
Global MailReport$ = ReadPreferenceString("MailReport","no")
|
||||
Global MailReport$ = LCase(ReadPreferenceString("MailReport","no"))
|
||||
Global MailTo$ = ReadPreferenceString("MailTo","")
|
||||
Global MailServer$ = ReadPreferenceString("MailServer","")
|
||||
Global MailPort = Val(ReadPreferenceString("MailPort",""))
|
||||
@ -239,7 +242,7 @@ Procedure EndProg(err)
|
||||
LogMe("return=" + err)
|
||||
|
||||
; send a report via mail ?
|
||||
If ( LCase(MailReport$) = "yes" )
|
||||
If ( MailReport$ = "yes" )
|
||||
LogMe("INFO: sending mail to: " + MailTo$)
|
||||
If ( LogSend(s$, Logfile$) )
|
||||
LogMe("INFO: mail sent")
|
||||
@ -324,16 +327,16 @@ If ( updatesched = 1 )
|
||||
jobcmd$ = ProgramFilename()
|
||||
|
||||
; check jobtype ...
|
||||
If ( LCase(BackupschedMode$) <> "login" And LCase(BackupschedMode$) <> "time" )
|
||||
If ( BackupschedMode$ <> "login" And BackupschedMode$ <> "time" )
|
||||
PrintN("WARNING: unknown BackupschedMode [ " + BackupschedMode$ + " ] ---> IGNORING. Type will be set to LOGIN.")
|
||||
BackupschedMode$ = "LOGIN"
|
||||
EndIf
|
||||
|
||||
; update the job ...
|
||||
PrintN ("Updating windows jobscheduler ...")
|
||||
If ( LCase(BackupschedMode$) = "time" )
|
||||
If ( BackupschedMode$ = "time" )
|
||||
dummy = system("schtasks /create /F /RL HIGHEST /SC daily /ST " + BackupStart$ + " /TN " + jobname$ + " /TR " + jobcmd$)
|
||||
ElseIf ( LCase(BackupschedMode$) = "login" )
|
||||
ElseIf ( BackupschedMode$ = "login" )
|
||||
dummy = system("schtasks /create /F /RL HIGHEST /SC onlogon /DELAY " + BackupStart$ + " /TN " + jobname$ + " /TR " + jobcmd$)
|
||||
EndIf
|
||||
|
||||
@ -348,15 +351,14 @@ If ( updatesched = 1 )
|
||||
EndIf
|
||||
|
||||
|
||||
;
|
||||
; ASK the user for permission to start ...
|
||||
;
|
||||
|
||||
; FTP backup requested ?
|
||||
If ( FtpBackup$ = "yes" )
|
||||
TargetPath$ = "ftp://" + TargetUser$ + "@" + FtpServer$ + TargetPath$
|
||||
EndIf
|
||||
|
||||
|
||||
;
|
||||
; ASK the user for permission to start ...
|
||||
;
|
||||
Result = MessageRequester("SnapControl",
|
||||
"Start BACKUP now?" + Chr(13) +
|
||||
"Targetpath => " + TargetPath$,
|
||||
@ -370,6 +372,17 @@ If Result = #PB_MessageRequester_No
|
||||
End 0
|
||||
EndIf
|
||||
|
||||
;
|
||||
; ASK the user for a shutdown ...
|
||||
;
|
||||
Result$ = InputRequester("SnapControl",
|
||||
"SHUTDOWN system after backup?" + Chr(13) +
|
||||
" (type 'yes' or 'no')", "no")
|
||||
|
||||
If LCase(Result$) = "yes"
|
||||
DoShutdown = 1
|
||||
EndIf
|
||||
|
||||
|
||||
; cleanup: delete old Logfile, remove old drive letter...
|
||||
dummy = DeleteFile(LogFile$, #PB_FileSystem_Force)
|
||||
@ -396,7 +409,7 @@ EndIf
|
||||
;
|
||||
|
||||
; encryption enabled ?
|
||||
If ( LCase(Encrypt$) = "yes" )
|
||||
If ( Encrypt$ = "yes" )
|
||||
params$ = "-PW=" + EncryptPW$ + " "
|
||||
If ( EncryptPW$ = "" )
|
||||
LogMe("WARNING: ENCRYPTED backup requested but PASSWORD is not set in infile !")
|
||||
@ -406,7 +419,7 @@ If ( LCase(Encrypt$) = "yes" )
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
If ( LCase(Encrypt$) = "dynamic" )
|
||||
If ( Encrypt$ = "dynamic" )
|
||||
If ( EncryptPW$ = "" )
|
||||
EncryptPW$ = mkpass(20)
|
||||
LogMe("WARNING: ENCRYPTED backup requested and DYNAMIC password was requested !")
|
||||
@ -427,12 +440,12 @@ If ( LimitIO$ <> "" )
|
||||
EndIf
|
||||
|
||||
; verify the backup ?
|
||||
If ( LCase(Verify$) = "yes" )
|
||||
If ( Verify$ = "yes" )
|
||||
params$ + "-T "
|
||||
EndIf
|
||||
|
||||
; burn all the trash in the recyclebin ?
|
||||
If ( LCase(BurnTrash$) = "yes" )
|
||||
If ( BurnTrash$ = "yes" )
|
||||
params$ + "-R "
|
||||
EndIf
|
||||
|
||||
@ -532,6 +545,13 @@ LogMe(" LogFile: [ " + LogFile$ + " ]")
|
||||
|
||||
If ( dryrun = 0 )
|
||||
e = system(SnapshotBin$ + " --Logfile:" + LogFile$ + " " + params$ + " " + DumpFile$ + " " + HashFile$)
|
||||
|
||||
If DoShutdown = 1
|
||||
LogMe("INFO: shutdown was requested ...")
|
||||
LogMe("INFO: executing [ " + ShutdownCommand$ + " ]")
|
||||
e = system(ShutdownCommand$)
|
||||
EndIf
|
||||
|
||||
EndIf
|
||||
|
||||
; end with return code...
|
||||
@ -539,8 +559,8 @@ EndProg(e)
|
||||
|
||||
; IDE Options = PureBasic 5.73 LTS (Windows - x64)
|
||||
; ExecutableFormat = Console
|
||||
; CursorPosition = 526
|
||||
; FirstLine = 500
|
||||
; CursorPosition = 384
|
||||
; FirstLine = 351
|
||||
; Folding = --
|
||||
; EnableXP
|
||||
; Executable = snapcontrol.exe
|
||||
|
Loading…
Reference in New Issue
Block a user