Scheduled backup of large directories using WinRar

There are many ways to backup data from a computer. Sometimes the requirements are such that you have to come up with a custom solution. In this particular case, apart from using hard drives in RAID volume, there has to be an scheduled backup on DVD-s which have to be stored in a location different from the location of the station.

So I decided to write an simple BATCH script which will archive and split the directory into parts suitable for burning on DVD. Then I schedule id with windows scheduler.

Here is the script:

@Echo Off
@For /F "tokens=1,2,3 delims=. " %%A in ('Date /t') do @( 
Set Day=%%A
Set Month=%%B
Set Year=%%C
Set All=%%C_%%B_%%A

set DirToCopy="E:\dirtobackup"

set DirToPaste="F:\backup_%ALL%\destdir\"

set DirToArchive="F:\backup_%ALL%\destdir"

set ArchiveFile="F:\backup_%ALL%\backup.rar"

set rarEXE="C:\Program Files\WinRAR\Rar.exe"

set volumeSize=4588544

xcopy /E /Y %DirToCopy% %DirToPaste%

%rarEXE% a -ag_YYYY_MM_DD -v%volumeSize%k %ArchiveFile% %DirToArchive% 

rem pause 

In brief this code gets the time from your computer. Copies the directory E:\dirtobackup in another drive F: in a folder (DirToPaste) containing the date of the backup. Then it archives and splits (in parts of 4588544 Kb which is appropriate size for burning on DVD) the copied directory.

Now all you need to do is to paste the code into a file with an .bat extension (Change the directory paths to match your needs). Add it to the scheduled tasks of your operating system. Burn on DVD after the script is executed.