+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, Robocopy script to move old backups to archive share in Coding and Web Development; Don't flame me too hard guys as I am command line-phobic and I am new to this. Basically, I want ...
  1. #1

    Join Date
    Oct 2010
    Posts
    3
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Robocopy script to move old backups to archive share

    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:
    Code:
     :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%

  2. #2

    Join Date
    Oct 2010
    Posts
    3
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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 :-(

  3. #3


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,075
    Thank Post
    232
    Thanked 2,721 Times in 2,008 Posts
    Rep Power
    797
    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
    Code:
    @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%

  4. Thanks to Arthur from:

    fat_techie_virgin (19th October 2010)

  5. #4

    Join Date
    Oct 2010
    Posts
    3
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. Robocopy Script
    By harrimann in forum Scripts
    Replies: 6
    Last Post: 5th January 2011, 11:41 AM
  2. Move to SQL 2008 and backups
    By thesthelensman in forum MIS Systems
    Replies: 2
    Last Post: 13th April 2010, 02:16 PM
  3. Rar archive with date backup script (.bat)
    By RabbieBurns in forum Scripts
    Replies: 1
    Last Post: 20th November 2009, 02:05 AM
  4. Replies: 17
    Last Post: 19th November 2008, 10:05 AM
  5. Replies: 8
    Last Post: 1st February 2007, 08:42 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •