ERASEFILES Command not working in script
davismisbehavis
Posts: 4
Trying to get some backups that are going to a local disk to delete after 3 days. Doesn't appear to be working.
Have attempted to use the FILEOPTION command as well but had no luck
Anyone able to help?
Have attempted to use the FILEOPTION command as well but had no luck
Anyone able to help?
SQLBackupC.exe -SQL "BACKUP DATABASES [*] TO DISK = 'X:\<TYPE>_<SERVER>_<DATABASE>_<DATETIME yyyymmdd_hhnnss>.sqb'" COMPRESS ION = 2, ERASEFILES = 3
Comments
The command has a syntax error, it misses WITH. Try this
and let us know if it still doesn't work.
Thanks,
Priya
Project Manager
Red Gate Software
I wasn't getting any syntax errors without the WITH but have added it in just in case.
I have tried running it again and it still isn't deleting the sqb files older than 3 days, however it is taking backups with compression so that switch is obviously working OK
Many thanks for your help on this
The reason is because there is a quoting error in the syntax... your script should read:
Your COMPRESSION=2 and ERASEFILES=3 syntax should be inside the double quotes... because it is not, the SQLBackupC.exe is ignoring the two keywords. The compression will still occur because the default is compression level 1.
Hope that helps,
Jason
You might be aware but I thought it is worth mentioning that in the last step of the Backup and Restore Wizard, you can view the scripts for 'Command Line' and 'Extended Stored Procedure' under the Script tabs. This might be useful for you.
Thanks,
Priya
Project Manager
Red Gate Software
That's exactly what it was, thanks
Priya
I didn't know that, I was writing this from scratch. Much handier if you can see the code on the back of the options selected in the GUI.
This is the way microsoft are going with Powershell in all their new stuff. so you can always see the scripting behind the GUI interface.
Thanks all