# Compressing files during a batch backup



## aaronshover (Aug 6, 2004)

Is there any way to compress files while they are being backed up via a batch file? The following is the batch file (no mocking please as I didn't create it).


```
@echo off
Rem
if exist "C:\Choice.com" goto Ready
copy "\\epsc0909s02\Backup\choice.com" "c:\"
Rem
:Ready
Rem This is designed for people in ADMINISTRATION.
Rem
Echo You are about to Backup the following Folders:
Echo "Desktop", "Favorites", "NetHood", "Outlook" and "My Documents"
Echo ----------------------------------------------------------------
Echo !!! Please make sure that all applications are closed !!!
Echo ----------------------------------------------------------------
c:\Choice "Are you Ready Y/N :"
Rem --- Errorlevel 1 is a yes answer
Rem --- Errorlevel 2 is a no answer
if errorlevel 2 goto Startover
if errorlevel 1 goto Begin
:Begin
Rem ------Begin
Rem
Rem Check to see if Directory exists
Rem
if exist "\\epsc0909s02\backup\AD\%username%" goto Process
Rem ------File does not exist
goto MakeDir
Rem
Rem Asking if they want to delete the old backup
Rem
:Process
Rem ------Process
c:\Choice "Do you want to delete your old backup Y/N :"  
if errorlevel 2 goto CopyIt
Rem ------Answered Yes
if errorlevel 1 goto AskAgain
Rem
Rem Ask Again
:AskAgain
c:\Choice "Are you sure you want to delete your old backup Y/N :"
Rem -----Answered No
if errorlevel 2 goto StartOver
Rem -----Answered Yes
if errorlevel 1 goto Dele
Rem
:Dele
Rem
Rem Deleting Old Backup Folders
Rem
Rd "\\epsc0909s02\backup\AD\%username%\favorites" /s /q
Rd "\\epsc0909s02\backup\AD\%username%\desktop" /s /q
Rd "\\epsc0909s02\backup\AD\%username%\nethood" /s /q
Rd "\\epsc0909s02\backup\AD\%username%\outlook" /s /q
Rd "\\epsc0909s02\backup\AD\%username%\my documents" /s /q 
Rem ------Finish Deleting Folders
goto CopyIt
Rem
Rem Create Backup Directory
Rem
:MakeDir
Rem ------Create Folder
mkdir "\\epsc0909s02\backup\AD\%username%"
Rem
ECHO *******************************************************************
ECHO **** PLEASE E-MAIL RUBEN THAT YOU HAVE BACKED UP YOUR FILES   *****
ECHO *******************************************************************
PAUSE
Rem Backup folders to Server EPSC0909S02\BACKUP\
Rem
:CopyIt
Rem
Rem Asking to run in quiet mode or not.
Rem
c:\choice "Do you want to see your files being copied. Y/N :"
if errorlevel 2 goto Quiet
Rem
Rem -------Starting XCopy of Folders
Rem Copy Desktop
Rem
xcopy "c:\Documents and Settings\%username%\desktop" /s /e /i /Y "\\epsc0909s02\backup\AD\%username%\desktop"
Rem
Rem Copy Outlook
Rem
xcopy "c:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Outlook" /i/s/e/Y "\\epsc0909s02\Backup\AD\%username%\Outlook"
Rem
Rem Copy Favorites
Rem
xcopy "c:\Documents and Settings\%username%\Favorites" /s /e /i /Y "\\epsc0909s02\backup\AD\%username%\Favorites"
Rem
Rem Copy NetHood
Rem
xcopy "c:\Documents and Settings\%username%\NetHood" /s /e /i /Y "\\epsc0909s02\backup\AD\%username%\NetHood"
Rem
Rem copy My Documents
Rem
xcopy "c:\Documents and Settings\%username%\My Documents" /s /e /i /Y "\\epsc0909s02\backup\AD\%username%\My Documents"
Rem
Rem Finish Copying
Rem
goto stop
:Startover
Rem -------Start Over
c:\Choice "Do you want to Start Over Y/N :"
if errorlevel 2 goto Stop
Rem
if errorlevel 1 goto Begin
Rem
Rem
:Quiet
Rem Run in quiet mode
echo ***************************************************
echo *** Please wait while files are being backed up ***
echo ***************************************************
Rem -------Starting XCopy of Folders
Rem Copy Desktop
Rem
xcopy "c:\Documents and Settings\%username%\desktop" /s /e /i /Y /q "\\epsc0909s02\backup\AD\%username%\desktop"
Rem
Rem Copy Outlook
Rem
xcopy "c:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Outlook" /i/s/e/Y/q "\\epsc0909s02\Backup\AD\%username%\Outlook"
Rem
Rem Copy Favorites
Rem
xcopy "c:\Documents and Settings\%username%\Favorites" /s /e /i /Y /q "\\epsc0909s02\backup\AD\%username%\Favorites"
Rem
Rem Copy NetHood
Rem
xcopy "c:\Documents and Settings\%username%\NetHood" /s /e /i /Y /q "\\epsc0909s02\backup\AD\%username%\NetHood"
Rem
Rem copy My Documents
Rem
xcopy "c:\Documents and Settings\%username%\My Documents" /s /e /i /Y /q "\\epsc0909s02\backup\AD\%username%\My Documents"
Rem
Rem Finish Copying
Rem
Rem It is all over
:Stop
echo ------ Finished!!!!
pause
```
If you could help me I'd greatly appreciate it!
Thanks.


----------



## draceplace (Jun 8, 2001)

Its my understanding that file compression saves 0.00 space on the drive. The system doesn't release the space it saved. Rather than trying to compress each backup how about winzip (or similar) on the already backed up files. Can this be run as a log off or logon script (when you know apps are closed) rather than confusing the users will simple Y/N question?


----------

