Script to use WinRAR for backups

REM winrar_backup.bat

echo off

SET FNAME=KIMCONNECT
SET LOGFILE=\\FILESERVER01\backup\ads-02-backup.txt

IF EXIST V:\ (
NET USE V: /DELETE
)

net use v: \\FILESERVER01\backup

IF %ERRORLEVEL% EQU 2 (
net use v: \\FILESERVER01\backup2
)

ECHO %USERNAME% >> %LOGFILE%
ECHO %USERPROFILE% >> %LOGFILE%
echo %computername% >> %LOGFILE%

ECHO "--------- NETWORK CONFIG ---------------"
IPCONFIG /ALL >> %LOGFILE%

REM -------------------------------------------------------
REM PARSE THE TIME CODE
REM -------------------------------------------------------
for /f "tokens=1-2 delims=: " %%a in ('time /t') do (set hours=%%a& set minutes=%%b)
echo The day is %hours% %minutes%


REM -------------------------------------------------------
REM PARSE THE DATE CODE
REM -------------------------------------------------------
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set weekday=%%a& set month=%%b& set day=%%c& set year=%%d)
echo The day is %WEEKDAY% %DAY%
echo The month is %MONTH%
set DCODE=%MONTH%.%DAY%.%YEAR%.TC.%HOURS%.%MINUTES%.rar

ECHO "STARTING BACKUP" >> %LOGFILE%
ECHO %DCODE% >> %LOGFILE%


REM -----------------------------------------------------------
REM GET THE DATE, AND MAKE A DIRECTORY IN THE BACKUP TREE
REM -----------------------------------------------------------
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do (set cdate=%%a.%%c)
ECHO %cdate%

rem GOTO END_PROGRAM

IF NOT EXIST v:\backup (
ECHO "BACKUP DIR"
MKDIR v:\backup
)

IF NOT EXIST v:\%cdate% (
ECHO "MAKING DIRECTORY"
MKDIR v:\%cdate%
)

REM -----------------------------------------------------------
REM NOTIFY ALL USERS
REM -----------------------------------------------------------
REM net send * "backup service shall begin immediately. exit apps now."

echo you are logged into %COMPUTERNAME%
if %USERNAME%==Administrator echo you are administrator
set RAREXEC="C:\Program Files\WinRAR\WinRar.exe"
set RAREXEC="C:\Program Files\WinRAR\Rar.exe"

set MD5SUMEXEC="C:\SYS\MD5SUM"

set SERVER=SBS2003
set SHARE1=sys

GOTO GROUP3

:GROUP3
echo "***************** NT SERVER SHARE 1 ********************"
%RAREXEC% u -r -m0 -msrar;zip;iso;cab;mp3;wmv v:\%cdate%\ADS-02.%DCODE% @alist.txt


:END_PROGRAM


net use v: /delete

Leave a Reply

Your email address will not be published. Required fields are marked *