Jump to content

BackupDetector ( Backup attention popup )

Recommended Posts

Have you ever shut down the computer while still performing a backup? 
If not, then ignore this post.

Otherwise, this program may be helpful.
It is registered in the startup folder after a query and then runs with every system start and ends only with system shutdown.
Whenever a backup activity begins or ends, a message is generated.
This prevents the computer from being accidentally turned off while a backup is still active.

;    BackupDetector.exe      Backup attention popup.

; Programm Name:    BackupDetector.exe
; Description:      Monitoring backup activities.
;                   Whenever a backup activity starts or ends, a message is generated.
;                   This eliminates the possibility of accidentally turning off the computer while a backup is still active.
; Syntax:           BackupDetector.exe     (no Parameters)
; Return Value(s):  None. It's a never ending programm.
; Author:           Exit   ( http://www.autoitscript.com/forum/user/45639-exit )
; SourceCode:       http://www.autoitscript.com/forum/index.php?showtopic=199161   Version: 2019.06.21
; COPYLEFT:         © 2019 Freeware by "Exit"
;                   ALL WRONGS RESERVED

#pragma compile(AutoItExecuteAllowed, True)
If Not @Compiled Then Opt("TrayIconHide", 0)
Opt("ExpandVarStrings", 1)

#include <_SingleScript.au3> ; http://www.autoitscript.com/forum/index.php?showtopic=178681
_SingleScript() ; Close all running scripts with the same name

$l = (StringRight(@OSLang, 2) = "07") ? 0 : 1 ; German=0  other=1

$sScriptShortcut = @AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\" & StringTrimRight(@ScriptName, 3) & "lnk"
If @Compiled Then
    If Not FileExists($sScriptShortcut) Then
        $rc = MsgBox(4 + 32 + 256 + 262144, Default, $l ? _
                "Should the program run at every system start?" : _
                "Soll das Programm bei jedem Systemstart ausgeführt werden?")
        If $rc = 6 Then
            $rc = FileCreateShortcut(@ScriptFullPath, $sScriptShortcut)
            MsgBox(64 + 262144, Default, ($rc ? "" : ("--> " & ($l ? "NO" : "KEINE") & " <-- ")) & _
                    ($l ? "Shortcut created in the startup folder." : "Verknüpfung im Startordner erstellt."))

$bMessagebox = False
$hPid = 0
While Sleep(5000)
    If ProcessExists("vssvc.exe") Then ; is Volume Shadow Copy running?
        If $bMessagebox = False Then
            If $hPid Then ProcessClose($hPid)
            $sText = $l ? "The backup is now running.      @HOUR@:@MIN@:@SEC@@LF@" & _
                    "Please do not turn off the computer." & @LF & _
                    "When the backup is finished, a new message appears." : _
                    "Die Sicherung läuft jetzt.      @HOUR@:@MIN@:@SEC@@LF@" & _
                    "Den Computer bitte nicht ausschalten." & @LF & _
                    "Wenn die Sicherung beendet ist, erscheint eine neue Meldung."
            $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep
            $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"'
            $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand)
            $bMessagebox = True
        If $bMessagebox = True Then
            If $hPid Then ProcessClose($hPid)
            $sText = $l ? "The backup is done.      @HOUR@:@MIN@:@SEC@@LF@" & _
                    "The computer can (but does not have to) be turned off." & @LF & _
                    "Thank you for your patience, now you can press 'OK'." : _
                    "Die Sicherung ist fertig.      @HOUR@:@MIN@:@SEC@@LF@" & _
                    "Der Computer kann (aber muss nicht) ausgeschaltet werden." & @LF & _
                    "Vielen Dank für ihre Geduld. Nun können Sie 'OK' drücken."
            $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep
            $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"'
            $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand)
            $bMessagebox = False

; End of BackupDetector script


Edited by Exit
altered language handling and added @computername to messagebox

App: Au3toCmd              UDF: _SingleScript()                             

Link to post
Share on other sites

I see no reason to run this program as a service.
The program can be registered in the startup folder and then runs automatically when the system is started.
Since no icon is displayed in the taskbar and system tray, it silently runs in the background.
So why run as a service?

App: Au3toCmd              UDF: _SingleScript()                             

Link to post
Share on other sites

The reason I listed it is because there are only upsides to a long running program being a service.  So in describing it, you described a slight downside.

1. Clutter. If you have apps that start on startup you will have to look all the way in the startup folder for this program rather than msconfig, as well as it won't take up room in the task manager.

The 2nd point is only true if the user has no login. But to be fair this is only slightly your fault if the backup software needs to be logged in to run. However there could be backup software could be created to these specs in the future.

2. The program can be started without being logged in if there is a hard reset rather the soft reset you describe, e.g. a power failure.

3. Service manager can automatically restart the program if it crashes without an external script.

Edited by moosjuice
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By rudi
      the following script is running quite nicely for a friend of mine doing a year of work and travel to have a backup at home for all the pics and movies taken with her mobile phone,
      The facts:
      At home: a VMWARE virtual machine with dropbox installed for her DB account
      On-the-Road: One mobile phone, Camera Uploads are activated for her dropbox account, one Laptop.
      The idea is to have a copy of *ALL* pictures and movies taken with the mobile phone *OUTSIDE* the dropbox folder, so that the DB Max Size is never exceeded.
      The script is running at home and doing this:
      Copy all content from the "Camera Upload Folder" within the dropbox folder to some folder *OUTSIDE* the DB folder Move all content from the "Camera Upload Folder" do some other folder *INSIDE* the DB folder to indicate, that the backup copies at home were done successfully  
      Dropbox is also installed on the Laptop she has with her. So on the Laptop she checks from time to time the destination folder inside the dropbox folder and moves the pics / movies on the laptop to some other folder outside the dropbox as well. By that final step the images are moved out of the dropbox on the mobile phone as well, so that there is always space left to sync more pics / movies.
      As moving pics / movies out of the dropbox folder on the laptop doesn't touch the copies in the mobile phone's "Gallery", she has all the pics / movies at all three locations:
      Mobile Phone Laptop VM at home  
      The folder names propably are different for non-German localized Windows and Dropbox, just modify them to meet your localization.
    • By careca
      This is a folder backup tool, after i got tired of using tools made by others, that had either lack of functionality,
      or were overly complex, i decided to make my own, and this is it.
      MirrorDir mirrors dirs as the name says, simply select source and destination hit scan, review in the list if that's what you want it to do and press start copy.
      As this is a mirror sync tool, this means files that exist in destination but dont exist in source are marked for deletion.
      Other tools have other modes like the incrementing copy which does not delete anything, but i made this for me,
      only if there is a request i may think about adding features just for fun.
      Whats more? There's a save/load of profile and the profile is what contains the list of source and destination folders, these are kept in prefs.ini in folder MDir in local appdata.
      There are context menu's that allow for the removal of items from the profile list, either just for the list (in case you dont want to sync a specific folder, just this time)
      or delete from the list and the .ini .
      Best regards.
    • By Marc
      Profiler - yet another backup script for Firefox and Thunderbird profiles
      It automatically detects the last recently used profile directories of Firefox and Thunderbird (installed versions, no portables).
      Clicking the Backup-Button creates a complete Backup of the found profiles with a timestamp.
      Restore deletes the according profile dir and extracts the content of the selected archive into the profile directory.
      Uses Winrar as compression tool, but feel free to change it to your needs
      Best regards

    • By Vivi
      hey guys,
      is there a way to post into the "Usenet" with autoit ?
      I didn't found any resources about it online.
    • By JohnOne
      "Nimps" is a regional slang word, which means easy or simple or basic and such.
      I made a quick little script the other day to backup the visual studio project folder I was actively working on.
      Thought I'd generalise it for use with the current active windows explorer folder.
      When this script is running, and you hit "Ctrl and Shift and b", if a folder is open in windows explorer, it will copy the contents of it to your desired location ($GENERAL_BACKUP_FOLDER) including subfolders and its files and folders (so beware on deep directories)
      If you have command line version of 7zip (7za.exe) you can choose to compress the folder rather than just copy it ($ZIP_FOLDER = True), or both I suppose.
      Think that's all.
      Reading the code should tell you anything else.
      Oh, success or failure is indicated by a high or low frequency Beep().
      #include <AutoItConstants.au3> #include <String.au3> HotKeySet("^+b", _Backup) ; ctrl and shift and b HotKeySet("!+b", _Exit) ; alt and shift and b Global Const $GENERAL_BACKUP_FOLDER = @ScriptDir & "Backup\" Global Const $ZIP_FOLDER = False Global Const $PATH_TO_7ZA = "D:\7za.exe" While 3 Sleep(300) WEnd ; High frequency beep if successful ; Low frequency beep if failed Func _Backup() Local $FOLDER_TO_BACKUP = "" Local $BACKUP_FOLDER = "" Local $CURRENT_BACKUP_FOLDER Local $WIN_TITLE = WinGetTitle("[Active]") Local $WIN_TEXT = WinGetText("[Active]") ; If text of window has no address, it is not a windows explorer If StringInStr($WIN_TEXT, "Address: ") Then Local $ACTIVE_EXPLORER_ADDRESS = _StringBetween($WIN_TEXT, "Address: ", @LF) If Not IsArray($ACTIVE_EXPLORER_ADDRESS) Then Beep(400, 150) Return @ScriptLineNumber EndIf $FOLDER_TO_BACKUP = $ACTIVE_EXPLORER_ADDRESS[0] Else Return MsgBox(0, "Info", "The active window is not explorer") EndIf ; Check to see if root drive is backup source If StringRight($FOLDER_TO_BACKUP, 2) = ":\" Then $Answer = MsgBox(4, "Warning", "You are about to attempt to backup a whole disk" & @CRLF & "Are you sure?") If $Answer <> 6 Then Return EndIf ; Date and time to append to backup zip file or folder $APPEND = "_" & @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC Local $CURRENT_BACKUP_FOLDER = $GENERAL_BACKUP_FOLDER & $WIN_TITLE & $APPEND ; Zip to backup folder and return, 7za.exe required If $ZIP_FOLDER Then ; Buile command for 7za $command = $PATH_TO_7ZA & ' a ' & '"' & $GENERAL_BACKUP_FOLDER & $WIN_TITLE & $APPEND & '"' & '.zip ' & '"' & $FOLDER_TO_BACKUP & '"' $pid = Run($command, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While ProcessExists($pid) Sleep(10) WEnd $out = StdoutRead($pid) ; Indicate if successfull If StringInStr($out, "Everything is Ok") Then Beep(700, 200) Return EndIf Beep(400, 200) Return EndIf ; Copy folder and beep when complete, no 7zip needed. Local $RTN = DirCopy($FOLDER_TO_BACKUP, $CURRENT_BACKUP_FOLDER, 1) ? Beep(700, 500) : Beep(400, 500) EndFunc ;==>_Backup Func _Exit() Exit EndFunc ;==>_Exit  
  • Create New...