Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to use sqlmaint.exe tool to back up a database on a remote PC. Here is an example of backup:

sqlmaint.exe -S remoteSQLServer\SQLInstance -U username -P pwdxxx -D myDB 
   -BkUpMedia DISK -BkUpDB C:\MSSQL_Backups -DelBkUps 3days ...

Here I specified to delete backups older than 3 days. However, the job seems not deleting old bak files on the remote PC(where the SQL server sits). The remote PC has Windows 2008 Server. I also set the C:\MSQL_Backups as shared network drive for EnyOne as owner. My understanding is that the job will delete any bak files older than 3 days. Not sure what I missed?

By the way, the job runs at a box with SQL server 2005 installed.

share|improve this question

migrated from Nov 18 '09 at 6:10

This question came from our site for computer enthusiasts and power users.

up vote 1 down vote accepted

I dont have experience with the sqlmaint.exe. especially on a windows server 2008. Install the newest MS SQL 2005 patches and try to run the command again. May be this helps.

Do you want to run the backup job regularly? You can create a maintenance plan with the sql management studio. In the Maintenance plan you can create a cleanup job which deletes the old backups.

the maintenance plans are a very good and stable way to create backups of your ms sql 2005 db's.

You also should set more restrictive access to the network share. else everyone can create a new database from your backups or just delete them for fun.

You could also take a look at the tool forfiles.exe. With this tool it's possible to search for files which meets some specified criteria and delete them (or do whatever you want).

Have a nice day.

share|improve this answer
I thought about cleanup job as separate process on a remote PC (where SQL db sits). If I can get sqlMaint.exe to work as expected, that would be great. – Nov 18 '09 at 16:51

This simple command will do what your are looking for on Windows 2003 server

forfiles /P D:\FTP\LocalUser\svrbkp\live\webfiles /s /D -30 /M *.zip /C " cmd /c del @path" Pls refer my blog

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.