This is a bit dated, but should work in theory with a little bit of modification. It was used when this company backed up to a cd writer. You could, in theory, just have it move to another drive instead.
@ECHO OFF
:: This file will perform daily (EOD) backups, catchup backups (backing up
:: dated subs previously missed), and EDC backups. The EDC backup is
:: performed as part of the daily (EOD) backup process and is incremental,
:: meaning it creates only one EDC.zip file on %ArchDrv% and updates that
:: file with new/changed EDC files daily.
:: DISCLAIMER:
:: While this batch file has been tested and appears to work as expected,
:: no warranty is implied or given. Use freely, but USE AT YOUR OWN RISK.
:: *********************************************************************************
:: Setup Requirements: Ensure the IBERDIR variable is defined on the system, *
:: PKZIP.EXE resides in the system's path, and ARCHDRV is properly defined *
:: (in the first line of code below the usage instructions). *
:: *********************************************************************************
:: *********************************************************************************
:: Usage: *
:: -Call archive.bat without arguements for daily (EOD) backups *
:: -Call archive.bat with the "catchup" argument to backup missing historical *
:: dated subs (i.e. "d:\aloha\bin\archive.bat catchup" without the quotes) *
:: *
:: This file is intended to be called by Windows Scheduler Service, not Aloha. *
:: Schedule it to be launched daily anytime after EOD is performed. One exception *
:: may be a breakfast restaurant whose EOD is in the afternoon. For this batch *
:: file to pick up the dated sub properly, it should be scheduled to run *
:: sometime after midnight, because it assumes the dated sub is yesterday. *
:: *********************************************************************************
:: Set drive in which to archive the files to below:
SET ARCHDRV=C:
:: This section moves all dated sub zip files to folder C:\Aloha_Backups. /y trigger allows overwrite of files with the same name.
:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
move /y "C:\20*.zip" "C:\Aloha_Backups"
:: This section gets dated sub to back up (assumes yesterday)
:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SETLOCAL ENABLEEXTENSIONS
:: Get current date in YYYYMMDD format
FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :FIXDATE %%G %%H %%I %%J)
goto :GETDATE
:FIXDATE
if "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
set %%G=%1&set %%H=%2&set %%I=%3)
goto :EOF
:GETDATE
:: Convert to Modified Julian date
if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2432046
set MJD=%j%
:: Subtract a day
set /a MJD=%MJD% - 1
:: Convert back to YYYYMMDD format
set /a a=%MJD%+2432045,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5
set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
endlocal&set datedsub=%yy%%mm%%dd%&set y=%yy%&set m=%mm%&set d=%dd%
:: Check if running in Catch-Up mode
IF /I "%1"=="catchup" GOTO ALL

AILY
:: This section is EOD backup - yesterday only
:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:: Check for existence of prior archive
IF EXIST %ARCHDRV%\%datedsub%.ZIP GOTO END
:: Delete *.CDX files from dated folder
DEL %IBERDIR%\%datedsub%\*.CDX
:: Zip the dated folder to the archive location
PKZIP.EXE %ARCHDRV%\%datedsub%.ZIP %IBERDIR%\%datedsub%\*.*
:: Backup all new/changed EDC files (incremental)
PKZIP.EXE -i -rp %ARCHDRV%\EDC.ZIP %IBERDIR%\EDC\*.*
:: Verify successful dated folder and EDC archive
IF NOT EXIST %ARCHDRV%\%datedsub%.ZIP GOTO FAILURE
IF NOT EXIST %ARCHDRV%\EDC.ZIP GOTO FAILURE
GOTO END
:ALL
:: This section is catchup backups - all dated subs
:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:CYCLE
:: Check for existence of dated sub to back up
IF NOT EXIST %IBERDIR%\%datedsub% GOTO END
:: Check for existence of prior archive
IF EXIST %ARCHDRV%\%datedsub%.ZIP GOTO HISTORY
:: Dated sub not yet archived, start backup process
:: Delete *.CDX files from dated folder
DEL %IBERDIR%\%datedsub%\*.CDX
:: Zip the dated folder to the archive location
PKZIP.EXE %ARCHDRV%\%datedsub%.ZIP %IBERDIR%\%datedsub%\*.*
:: Verify successful dated folder archive
IF EXIST %ARCHDRV%\%datedsub%.ZIP GOTO HISTORY
GOTO FAILURE
:HISTORY
:: This section goes back one more day each time thru...
:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SETLOCAL ENABLEEXTENSIONS
set yy=%y%&set mm=%m%&set dd=%d%
:: Convert to Modified Julian date
if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2432046
set MJD=%j%
:: Subtract a day
set /a MJD=%MJD% - 1
:: Convert back to YYYYMMDD format
set /a a=%MJD%+2432045,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5
set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
endlocal&set datedsub=%yy%%mm%%dd%&set y=%yy%&set m=%mm%&set d=%dd%
GOTO CYCLE
:FAILURE
:: Failure Message
:: ~~~~~~~~~~~~~~~
Echo. > %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo ******************************************* >> %IBERDIR%\TMP\ArchErr.TXT
Echo ***WARNING*** ***WARNING*** >> %IBERDIR%\TMP\ArchErr.TXT
Echo ******************************************* >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo *** THIS IS VERY IMPORTANT! *** >> %IBERDIR%\TMP\ArchErr.TXT
Echo *** DO NOT IGNORE THIS MESSAGE! *** >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo There was an error while creating the >> %IBERDIR%\TMP\ArchErr.TXT
Echo backup for %datedsub% date of business. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo The most likely cause is that the >> %IBERDIR%\TMP\ArchErr.TXT
Echo CD is not in the CD writer or the >> %IBERDIR%\TMP\ArchErr.TXT
Echo CD in the CD writer is full. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo Check the CD status, insert and format >> %IBERDIR%\TMP\ArchErr.TXT
Echo a new CD using Roxio DirectCD Format >> %IBERDIR%\TMP\ArchErr.TXT
Echo Utility, found in Start/Programs/Roxio >> %IBERDIR%\TMP\ArchErr.TXT
Echo Easy CD Creator 5, if required. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
Echo. >> %IBERDIR%\TMP\ArchErr.TXT
GOTO END
Exit
:END