none
Issue with simple Backup Script_RoboCopy RRS feed

  • Question

  • I'm trying to create a simple backup script with robocopy that creates a directory with the current date for back ups once a week, without replacing the previous backup folder. 

    I'm getting a syntax error 

    2014/01/21 09:33:18 ERROR 123 (0x0000007B) Accessing Destination Directory C:\Backup"2014-01-21"\ The Filename, directory name, or volume label syntax is incorrect. 

    Here is my script:

    @echo off
    Title TEST BACKUP
    Color 0a
    SET folderdate="%date:~10,4%-%date:~4,2%-%date:~7,2%"
    md C:\Backup\%folderdate%
    cd C:\Backup\%folderdate%
    ROBOCOPY "C:\School" "C:/Backup\%folderdate%" /MIR /COPYALL /R:3 /W:3 /XO 
    pause

    Thanks in Advance for any help!

    Logan


    Tuesday, January 21, 2014 3:41 PM

Answers

  • The quotation marks around the folderdate variable are being inserted into destination folder in the call to robocopy.

    Remove the quotation marks from your folderdate line:

    @echo off
    Title TEST BACKUP
    Color 0a
    SET folderdate=%date:~10,4%-%date:~4,2%-%date:~7,2%
    md C:\Backup\%folderdate%
    cd C:\Backup\%folderdate%
    ROBOCOPY "C:\School" "C:/Backup\%folderdate%" /MIR /COPYALL /R:3 /W:3 /XO 
    pause


    • Proposed as answer by Mike Laughlin Tuesday, January 21, 2014 4:26 PM
    • Marked as answer by Logan786 Tuesday, January 21, 2014 4:35 PM
    Tuesday, January 21, 2014 4:02 PM

All replies

  • The quotation marks around the folderdate variable are being inserted into destination folder in the call to robocopy.

    Remove the quotation marks from your folderdate line:

    @echo off
    Title TEST BACKUP
    Color 0a
    SET folderdate=%date:~10,4%-%date:~4,2%-%date:~7,2%
    md C:\Backup\%folderdate%
    cd C:\Backup\%folderdate%
    ROBOCOPY "C:\School" "C:/Backup\%folderdate%" /MIR /COPYALL /R:3 /W:3 /XO 
    pause


    • Proposed as answer by Mike Laughlin Tuesday, January 21, 2014 4:26 PM
    • Marked as answer by Logan786 Tuesday, January 21, 2014 4:35 PM
    Tuesday, January 21, 2014 4:02 PM
  • Always the little things.  I tested the script with the changes you suggested and it ran flawlessly.  

    Thank you for your help!

    -Logan 

    Tuesday, January 21, 2014 4:20 PM