@echo off echo jsbkwin :: INSTRUCTIONS: :: Save this file to it. Remove the .txt from the name. :: Download https://github.com/muquit/mailsend and copy into c:\winnt or c:\windows, rename to mailsend.exe :: Ideally, you will just send the mail directly. But more and more ISP's are blocking this. You can request that your ISP allow smtp or send on another port or use a remote mail server. :: Also, http://www.cygwin.com/ for rsync, ssh and unix2dos on windows. :: Edit file according to your needs and run. :: This can be run automatically with "at" or "scheduled tasks", :: You can uncomment the pause's for debugging. ::uncomment options as needed (connecting to outside MTA, for example) set to="" set from="" set smtp_server="127.0.0.1" ::set smtp_port="587" ::set username="" ::set password="" set subject="Backup log from %computername%" set log="jsbkwin_log.txt" ::File extensions to be excluded, uncomment and modify as needed. ::echo .avi >> exclude.txt ::echo .mp3 >> exclude.txt echo exclude.txt >> exclude.txt ::XCOPY help :: /s copied recursively except empty dirs :: /e copies empty dirs :: /v verifies file writes :: /y answers yes with out prompt :: /i assumes dirs are dirs (duhh) :: /h copies hidden and system files :: /d copies new or changed files :: /EXCLUDE:[file] files or strings to exclude :: >> %log% 2>&1 redirects standard out and error and appends to log echo. echo Press "X" at top right of window to cancel. echo backup screen will be blank throughout backup process. Check log for echo activity and results. echo log location: %log% ::uncomment "pause" for running manual or troubleshooting ::pause echo. echo ----------BEGIN---------- >> %log% date /t >> %log% 2>&1 time /t >> %log% 2>&1 echo. echo Backed up files: echo. echo running backup now >> %log% 2>&1 ::example :: C:\cygwin\bin\rsync -rut --delete --stats "/cygdrive/c/DATA" "/cygdrive/e/daily/rsync-mirror" >> %log% 2>&1 :: C:\cygwin\bin\rsync -rut --delete --stats "/cygdrive/c/MT0" "/cygdrive/e/daily/MT0" >> %log% 2>&1 ::echo. >> %log% 2>&1 ::echo. >> %log% 2>&1 ::echo running new-n-changed backup now >> %log% 2>&1 ::echo. >> %log% 2>&1 :: xcopy /s/e/v/y/i/h/d/EXCLUDE:exclude.txt "c:\DATA" "e:\daily\new-n-changed" >> %log% 2>&1 ::echo. >> %log% 2>&1 ::echo. >> %log% 2>&1 ::Using http://sf.net/projects/freefilesync echo running freefilesync backup now >> %log% 2>&1 ::"C:\Program Files\FreeFileSync\FreeFileSync.exe" "C:\scripts\ffs_backup.ffs_batch" ::if errorlevel 1 ( :: 0 = sync completed successfull, 1 = sync completed with errors, 2 = sync was aborted ::echo Errors occured during freefylesync execution >> %log% 2>&1 ::) echo. date /t >> %log% 2>&1 time /t >> %log% 2>&1 echo ----------END---------- >> %log% echo. ::if using cygwin (rsync) be sure to uncomment ::C:\cygwin\bin\unix2dos.exe %log% echo mail log mailsend -starttls -auth -mime-type "text/plain" -msg-body %log% -t %to% -sub %subject% -f %from% -smtp %smtp_server% -port %smtp_port% -user %username% -pass %password% ::example to send directly from host (not through mailserver) :: mailsend -msg-body %log% -t %to% -sub %subject% -f %from% -smtp %smtp_server% -port %smtp_port% ::example blat switches, deprecated because it doesn't support tls natively :: blat %log% -to %to% -subject %subject% -hostname %computername% -server %smtp_server% -i %from% -f %from% -port %smtp_port% -u %username% -pw %password% del exclude.txt move /y %log% lastbackuplog.txt echo. echo BACKUP COMPLETE ::uncomment "pause" for troubleshooting ::pause ::stunnel.conf example: ::client = yes ::debug = debug ::[pop3s] ::accept = 127.0.0.1:9995 ::connect = pop3s.myisp.com:995 ::[imaps] ::accept = 127.0.0.1:9993 ::delay = yes ::connect = imaps.myisp.com:993 ::[smtps] ::accept = 127.0.0.1:4465 ::connect = smtps.myisp.com:465