@echo off

rem Automatic Windows Backup Script for Workstations
rem
rem This script tars the files to be backup'ed together into one archive,
rem creates an ISO-image of the tar-archive and burns it onto a CD with the
rem help of cdrecord
rem
rem (c) 2006 by Alexander Griesser <work@tuxx-home.at>

rem Get the current date
set TODAY=%DATE:~0%

rem ============================ CONFIGURATION ========================
rem Specify an Identifier for this Backup
set ITEM=Tagname

rem The Backup-Root directory (the necessary tools also have to reside here)
set BACKUP_ROOT=C:\Backup

rem Path to the logfile
set LOGFILE=%BACKUP_ROOT%\Backup-%ITEM%.log

rem cdrecords burning device identifier (use cdrecord -scanbus to get
rem that info)
set CDDEVICE=2,0,0

rem Activate this setting if you need to copy files from another
rem computer in your network to this computer
rem set BACKUP_DIR=%BACKUP_ROOT%\%ITEM%
rem ===================================================================

echo Automatic Windows Backup for Workstations
echo
echo Please ensure that the CD burner is connected to your PC and
echo that a CD is inserted and press Enter when ready.
pause

rem Activate this command to copy files from another computer to this
rem machine for backup (you will need the robocopy utility from the
rem Microsoft Windows Ressource Kit for this - or any other utility
rem that does the trick)
rem echo Copying files from remote computer(s)...
rem %BACKUP_ROOT%\robocopy.exe \\otherpc\C$\application %BACKUP_DIR%\application /E /R:5 /W:5 /LOG:%LOGFILE%

rem Creation of the backup archive by either using local folders (for backing
rem up this computer) or by using %BACKUP_DIR% as source (when copying files
rem from remote computers)

echo Creating Backup Archive...
%BACKUP_ROOT%\tar.exe -cf %BACKUP_ROOT%\%ITEM%-%TODAY%.tar C:\\application C:\\application2 "%USERPROFILE%\\Eigene Dateien" "%USERPROFILE%\\Lokale Einstellungen\\Anwendungsdaten\\Microsoft\\Outlook" >%LOGFILE%

rem echo Creating Backup Archive for remote computer(s)...
rem %BACKUP_ROOT%\tar.exe -cf %BACKUP_ROOT%\%ITEM%-%TODAY%.tar %BACKUP_DIR% >>%LOGFILE%

echo Creating CD-Image...
%BACKUP_ROOT%\mkisofs.exe -J -v -o %BACKUP_ROOT%\%ITEM%-%TODAY%.iso %BACKUP_ROOT%\%ITEM%-%TODAY%.tar >>%LOGFILE%

echo Deleting temporary files...
del /F /Q %BACKUP_ROOT%\%ITEM%-%TODAY%.tar >>%LOGFILE%

echo Burning CD
echo This make take some time, please be patient. A progress meter is being
echo displayed during the burning process and after the backup has
echo completed successfully, the CD will be ejected.
echo
%BACKUP_ROOT%\cdrecord dev=%CDDEVICE% gracetime=0 -tao -verbose -eject -data %BACKUP_ROOT%\%ITEM%-%TODAY%.iso
echo Deleting temporary files
del /F /Q %BACKUP_ROOT%\%ITEM%-%TODAY%.iso
echo
echo Backup completed successfully
echo
echo Please check if the CD is readable and that it contains a file
echo named %ITEM%-%TODAY%.tar
echo
pause