Deleting files from backup drive

  • Hi

    I am calling this below command from .cmd batch file as I have no SQL Agent (express edition). But getting the below error while I try to run that in command prompt.

    What is the cause of the error? Is this a syntactical error?

    forfiles -p "C:\Program Files\Microsoft SQL Server\Backup\" -s -m *.bak -d -5 -c "cmd /c del @path"

    Error:

    ERROR: Invalid argument/option - '@path'.

    Type "FORFILES /?" for usage.

    Thanks.

  • SQL-DBA-01 (12/16/2016)


    Hi

    I am calling this below command from .cmd batch file as I have no SQL Agent (express edition). But getting the below error while I try to run that in command prompt.

    What is the cause of the error? Is this a syntactical error?

    forfiles -p "C:\Program Files\Microsoft SQL Server\Backup\" -s -m *.bak -d -5 -c "cmd /c del @path"

    Error:

    ERROR: Invalid argument/option - '@path'.

    Type "FORFILES /?" for usage.

    Try using cmd.exe instead of just cmd and see if that makes a difference.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • the example here:

    http://ss64.com/nt/syntax-delolder.html

    is so close to your version, i'm not sure there's an issue:

    the only thing i see is that the example uses slashes instead of hypens for the parameters.

    forfiles /p "C:\source_folder" /s /m *.* /c "cmd /c Del @path" /d -7

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • This was removed by the editor as SPAM

  • SQL-DBA-01 (12/16/2016)


    Hi

    I am calling this below command from .cmd batch file as I have no SQL Agent (express edition). But getting the below error while I try to run that in command prompt.

    What is the cause of the error? Is this a syntactical error?

    forfiles -p "C:\Program Files\Microsoft SQL Server\Backup\" -s -m *.bak -d -5 -c "cmd /c del @path"

    Error:

    ERROR: Invalid argument/option - '@path'.

    Type "FORFILES /?" for usage.

    You should not be deleting backup files according to the number of days or by date because <insert drum roll here> if something has been going wrong with your backups, you may end up with NO backup files.

    You need to make sure that some backup files are present within (according to your code) the 5 days before you go deleting backups that are older than 5 days. Voice of experience here on this one.

    --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)

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

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