Batch Files to back up main computer

It was suggested I put this here:

In the days of DOS the best way to get anything done on a computer was via a batch file. The facility still remains (and much improved) with Windows computers up to and including Win8. It allows you to do everything a GUI program does but  much quicker. I have been using batch files to back up all my personal files since Noah was a boy and until I bought a WD EX4 never had any trouble with any of the commands.

I mostly use the older Xcopy command but occasionally use Robocopy with the /mir argument however on my EX4 currently this_ _ command is refused permission to delete files even though it has no trouble writing files. I also use a ReadyNas and it allows Robocopy to either write or delete files.

Has anybody here used Batch Files to back up? it works well except for the flaw on the EX4  mentioned above. I use two files one to determine which machine to backup to which calls another one to select the folders to be backed up. This is far quicker than any other backup program I have come across.

This file decides which NAS machine to pass the data to, it is called by a normal Windows shortcut (but could be called by the activity timer thingy in Windows):


@echo off

rem get day of month (first two digits)
set mynum=%date:~4,2%

rem get rid of leading zero
SET /A mynum = 100%mynum% %% 100

rem Find if EVEN or ODD result = 0 or 1
SET /A mynum = %mynum% %% 2

if %mynum% == 0 (
echo.
echo         Today is EVEN date so Backing Up to ReadyNAS
call ACERUniversalBackup.bat NoPause \NAS-BCL\
) else (
echo.
echo         Today is ODD date so Backing Up to WD EX4 NAS
call ACERUniversalBackup.bat NoPause \BCLWDEX4\
)

echo.

rem Check if the computer is to be shutdown at the comclusion of the backup
if “%1” == “Shutdown” goto shutdown
echo.
goto finnish

:shutdown
echo.
echo         Computer is going to shutdown automatically…
echo.
call shutdown.exe /s /t 10
echo.

:finnish

 ----

The following file copies the data to the approriate NAS. Rather than bore you with the whole thing I have snipped out the repeating detail. Toward the end you can see where I have changed the way it handles the Calibre Library files (epub and meta data) because of the permission problems.

---- Start Batch file ACERUniversalBackup.bat

@echo off
rem          Backing up ACER-PC
rem          %1 = NoPause - if something else batch file will stop for user input
rem          %2 = either \NAS-BCL\ or \BCLWDEX4\
rem          Set the parameters
if [%2] == [] goto ending
SET NASDevice=%2
SET NASPath=%NASDevice%backup\
rem          Check NAS is on
if not exist “%NASPath%” goto fin
rem          Set path to include computer name
set NASPath=%NASPath%%computername%
echo.
echo         Batch file running:
echo.
echo         %0  %2
echo.
echo         Backing up Acer Computer files to %2
echo.
echo.
echo         Checking ACER-PC My Docs…
echo.
SET ThisPath=%NASPath%\Documents\
xcopy “%userprofile%\Documents\*.*” “%ThisPath%” /y /d /s /exclude:NASExcludeList.txt
echo.

echo         Check Calibre Library…

rem  This needed due to permissions problem on NAS WD EX4
SET ThisPath=%NASPath%\DDrive\Calibre Library

if [%2] == [\BCLWDEX4] goto NASEX4
robocopy “D:\Calibre Library” “%ThisPath%” /mir /R:1
echo.
goto Contin
:NASEX4
xcopy  “D:\Calibre Library\.*" “%ThisPath%” /y /d /s
:Contin
echo         Backup ACER-PC Micro$oft Templates…
echo.
SET ThisPath=%NASPath%\Templates\
xcopy "%appdata%\Microsoft\Templates\
.*” “%ThisPath%” /d /y /s
echo.
echo.
echo         Finished Backing up Acer Desktop…
echo.
goto ending
:fin
echo.
echo         WWWWHHHOOOPPPSSS!!!
echo.
echo         %2 is NOT turned on…
echo.
:ending
echo         That’s the lot…
echo         Thank you and Goodnight!
echo.
if “%1” == “NoPause” goto ending
echo.
echo         Ok, it’s finished so now you must
echo.
pause
:ending

----  END Batch file ACERUniversalBackup.bat

Any ideas how to get over this? How can I tell the EX4 to allow deletions? It is very frustrating.