fat_techie_virgin Posted October 8, 2010 Posted October 8, 2010 Don't flame me too hard guys as I am command line-phobic and I am new to this. Basically, I want to setup a test system before rolling out to production. I want to copy the folder structure of the backup area, and move any files contained there that are over 60 days old and are not in the folders and files I have specified. I also want to keep the file attributes regarding security and time stamps etc. I have scheduled this test script and it ran, but didn't actually move anything. I would greatly appreciate help in finding out where I have gone wrong. Basically, I have cannibalised various scripts I found on the internet to come out with what is below: :START SET robo_path="\\server1\"%RoboCopy%" SET source_dir="\\server1\tom_temp" SET dest_dir="\\server2\Backup_Archive" SET log_fname="\\server2\Backup_Archive\Backup_Logs\Backup_Archive.txt" SET what_to_copy=/COPY:DAT /MOV /B /MIR SET exclude_dirs=/XD "banks" "colin temp" SET exclude_files=/XF /MINAGE:60 *.tmp "vssver.scc" SET options=/R:1 /W:1 /LOG+:%log_fname% /NFL /NDL /E /XJ %robo_path% %source_dir% %dest_dir% %what_to_copy% %options% %exclude_dirs% %exclude_files%
fat_techie_virgin Posted October 8, 2010 Author Posted October 8, 2010 Hi, Good spot on the extra ". I copied the rest of the first line without really knowing what it meant - i assumed % meant any (or the system) directory. I changed it to SET robo_path="\\server1\c$\RoboCopy.exe" but it still doesn't work :-(
Arthur Posted October 8, 2010 Posted October 8, 2010 Here's a slightly different version of your script. Since I wasn't sure which operating system you are using I made the script look for RoboCopy.exe in the same folder as the batch file. BackupArchive.cmd @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET SCRIPTPATH=%~dpnx0 SET SCRIPTDIR=%~dp0 SET SCRIPTDIR=%SCRIPTDIR:~0,-1% :: RoboCopy Settings SET SOURCE="\\Server1\tom_temp" SET DESTINATION="\\Server2\Backup_Archive" SET LOG_FNAME="\\Server2\Backup_Archive\Backup_Logs\Backup_Archive.txt" SET WHAT_TO_COPY=/COPY:DAT /MOV /B /MIR SET EXCLUDE_DIRS=/XD "banks" "colin temp" SET EXCLUDE_FILES=/XF /MINAGE:60 *.tmp "vssver.scc" SET OPTIONS=/R:1 /W:1 /LOG+:%log_fname% /NFL /NDL /E /XJ :: Start backup Start "" /Wait "%SCRIPTDIR%\RoboCopy.exe" %SOURCE% %DESTINATION% %WHAT_TO_COPY% %OPTIONS% %EXCLUDE_DIRS% %EXCLUDE_FILES% 1
fat_techie_virgin Posted October 19, 2010 Author Posted October 19, 2010 Thanks to both for your assistance. Unfortunately I still could not get it to work, so I used the free technet download Robocopy.gui to start from scratch and that was actually OK. I recommend any Robocopy newbies to check it out.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now