Skip to content

Instantly share code, notes, and snippets.

@jonnyreeves
Created July 5, 2015 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonnyreeves/303e92de419336b0e568 to your computer and use it in GitHub Desktop.
Save jonnyreeves/303e92de419336b0e568 to your computer and use it in GitHub Desktop.
Windows GMVault Setup

This guide runs you through setting up a GMVault backup as a Scheduled Task on Windows complete with email notification on failure.

Prerequesit software

  1. Download and install gmvault for windows.
  2. Download BLAT, unzip and copy to %LOCALAPPDATA%/blat
  3. Download and install stunnel to %LOCALAPPDATA%/stunnel

GMVault

  1. Perform an initial sync for your account gmvault sync --db-dir=D:\backup\gmvault your@email.addy
  2. Create a Scheduled Task which executes the following:
  • Program: %LOCALAPPDATA%\gmvault\gmvault.bat
  • Arguments: sync --db-dir D:\backup\gmvault --type quick your@email.addy
  • Start in: %LOCALAPPDATA%\gmvault

Email Notification on Task Failure

  1. Replace the contents of %LOCALAPPDATA%/stunnel.conf with: # GLOBAL OPTIONS client = yes output = stunnel-log.txt debug = 0 taskbar = no

     # SERVICE-LEVEL OPTIONS
     [SMTP Gmail]
     accept = 127.0.0.1:1099
     connect = smtp.gmail.com:465
    
     [POP3 Gmail]
     accept = 127.0.0.1:1109
     connect = pop.gmail.com:995
    
  2. Install stunnel as a service by opening an Administrator command prompt and executing: %LOCALAPPDATA%/stunnel/stunnel -install

  3. Start the Stunnel SSL Wrapper Service and check it is set to start Automatically in future.

  4. Configure blat so it can send mail via your Google email account (You'll need to create a new one-time password if you are using two-factor auth): %LOCALAPPDATA%/blat/blat -install 127.0.0.1 %COMPUTERNAME%@domain.com - 1099 - your@email.addy one-time-password

  5. Check your stunnel and blat configuration by sending a test email: %LOCALAPPDATA%/blat/blat -debug -subject "Blat Test" -body "it works!" -to your@email.addy

  6. Use the following batch file to create a Scheduled Task which checks for failed tasks and emails you.

TO_EMAIL="your@email.adddy"

for /F "delims=" %%a in ('schtasks /query /v /fo:list ^| findstr /i "Taskname Result"') do call :Sub %%a 
goto :eof 

:Sub 
set Line=%* 
set BOL=%Line:~0,4% 
set MOL=%Line:~38% 

if /i %BOL%==Task ( set name=%MOL% goto :eof ) 

set result=%MOL% 
echo Task Name=%name%, Task Result=%result% 

if - %result%==0 ( 
  blat -to %TO_EMAIL% -subject "Warning! Failed Scheduled Task on %computername%" -body "Task %name% failed with result %result% "
)

Further Reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment