Link to home
Start Free TrialLog in
Avatar of Vas
VasFlag for United States of America

asked on

Windows scripted FORFILES / del function (on Server 2012)

I'm using a script that I got from here which automates a mySQL dump of all databases, .zip's them, and then deletes all the .zip files older that what you specify:
http://www.redolive.com/utah-web-designers-blog/automated-mysql-backup-for-windows/

The site says the script is tested on Server 2008.  I'm running this on Server 2012.


The script is working except for the delete the older .zip files part, which is this line of the script:


echo “Deleting zip files older than x days now”
Forfiles -p %backupfldr% -s -m *.* -d -%retaindays% -c “cmd /c del /q @path”

Open in new window



If I run the script from the command line, at this part it errors with:

ERROR: Invalid argument/option - '/q'.
Type "FORFILES /?" for usage.


If I remove the /q part from the script just to see what happens, it then complains about a different part of the command:

ERROR: Invalid argument/option - '@path'.
Type "FORFILES /?" for usage.



This is the only script I found that can automate MySQL backups on WIndows fully (with archiving, deleted .sql files, and then deleting older .zip files).

I'm guessing something must be different in Server 2012.  

Any idea what should be fixed for that line above?



Thank you
Avatar of oBdA
oBdA

Have a really, really close look at the command you're trying to run, as it is posted here, and as it is in your editor.
You'll notice that the quotes around the command are "prettified". Delete all these "curly" quotes and replace them with proper straight ones, then try again.
“cmd /c del /q @path” (incorrect double quotes for scripting)
"cmd /c del /q @path" (correct double quotes for scripting)

Open in new window

Avatar of Vas

ASKER

I think it's just in this browser that it pasted that way.  The script has the correct quotes and also just in case I re-typed the straight quotes to be sure and still getting the same error:


User generated image
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vas

ASKER

That fixed it thanks!