Powershell Robocopy Help.. -second attempt to post(?)

  • --tried posting this but it failed for some reason.. if there is more than one thread I will delete..

     

    Hey guys, this should probably be on sourceforge or something but I thought I'd hit you guys up with this weird issue I'm having with archiving my backups

    Here is the command

    robocopy $FilePath $FinalPath $FileName /SEC /E /XX /A-:SH /IS /IT /r:3 /w:10

    Here are what the variables populate as

    $FilePath
    \\SomeServer\SqlProdbackups\SomeSQLServer\SomeInstance_Bup\SomeDatabase\Daily Pre-Cycle Full BU



    $FinalPath
    \\SomeServer\\SQLProdBackups\ARCHIVE\2019April\SomeSQLServer\SomeInstance_Bup\SomeDatabase\Daily Pre-Cycle Full BU
    $FileName
    "SomeDatabase_Full_20190329 194002.bak"

     

    So part of the problem here is the file name above has a space in it.. not my choice.. inherited this.. but thats why I quoted it out.. here is what robocopy is doing when passed those variables

    PS C:\Windows\system32> robocopy $Filepath ,$FinalPath, $FileName /SEC /E /XX /A-:SH /IS /IT /r:3 /w:10

    -------------------------------------------------------------------------------

    ROBOCOPY :: Robust File Copy for Windows

    -------------------------------------------------------------------------------

    Started : Wednesday, May 1, 2019 11:26:50 AM

    Source - \\SomeServer\SqlProdbackups\SomeSQLServer\SomeInstance_Bup\SomeDatabase\Daily Pre-Cycle Full BU

    Dest -\\SomeServer\\SQLProdBackups\ARCHIVE\2019April\SomeSQLServer\SomeInstance_Bup\SomeDatabase\Daily Pre-Cycle Full BU" SomeDatabase_Full_20190329

    Files :

    Options : /DCOPY:DA /COPY:DAT /R:1000000 /W:30

    ------------------------------------------------------------------------------

    ERROR : Invalid Parameter #3 : "194002.bak /SEC /E /XX /A-:SH /IS /IT /r:3 /w:10"

     

    I tried quoting out the file name as you see above.. but its still splitting it up for some reason.. I also tried specifying /File:  but robocopy wont allow this.. was wondering if anyone had any insight into whats going on here

  • just to notate this too.. I tried using commas in my final attempt to try to get this to separate ..it didnt work obviously... I did not have the commas there before.

  • welp.. nevermind.. finally found a forum post that helped.. apparently powershell robocopy doesn't like you to end your folder paths with a \ .. moved this and quoted everything.. worked fine

  • Just ran across this.  Yeah... you file path has spaces in it, as well, and so it needed to be quoted.  I got into the habit of automatically encapsulate such things in quotes.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • The issue here though didnt actually end up being the quoting, although I did ultimately end up quoting everything.. its that with powershell robocopy you apparently cant end folder desitnations with

    now I only ran into this issue when I had a folder ending with \  AND the file name had a space in it.. it ran fine for most of my backups.  One of my first trouble shooting steps after the fact was to quote everything out but it didn't fix the issue until I removed the trailing \ at the end of the folder path.. very bizarre.

    Of note.. this is apparently only an issue when you're using robocopy through powershell, this doesn't occur in standard robocopy(CMD).

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply