Tuesday, March 15, 2011

DPMbackup Invalid command -db.

The DPMbackup.exe command is a very useful tool to make a copy of your DPM database to a disk location. Using this copy you can easily recover from a corrupt database.

For our customers a use a scheduled task to make a dump of the DPM to disk on a daily bases. It has saved me from a full reinstall more then ones.

The issue I run in to is that the command DPMbackup –DB works perfectly from the command prompt, but when I use it in a script it gives me the following eror  {Error: Invalid command –db.}

In my case it worked to specify the instance name as well. Like: DpmBackup.exe -db -instanceName MSDPM2010

Full Script

@Echo off
SET LOGFILE="E:\Backup_folder\SQL Daily Backup\DPMSQLBACKUP.LOG"
SET backupfile="C:\Program Files\Microsoft DPM\DPM\Volumes\ShadowCopy\Database Backups\DPMDB.bak"
SET backuppath="E:\Backup_folder\SQL Daily Backup\"

for /f "tokens=2,3,4 " %%x in ("%date%") do set dstamp=%%z%%y%%x
for /f "tokens=1,2,3 " %%x in ("%time%") do set tstamp=%%x%%y%%z

ECHO ===================================================================>> %LOGFILE%
ECHO %dstamp% - %tstamp% >> %LOGFILE%
ECHO ===================================================================>> %LOGFILE%
DpmBackup.exe -db -instanceName MSDPM2010 >> %LOGFILE%
if not exist %backupfile% goto NOTEXIST
IF Exist %backuppath%\DPMDB_05.* del %backuppath%\DPMDB_05.*
IF Exist %backuppath%\DPMDB_04.* ren %backuppath%\DPMDB_04.* DPMDB_05.*
IF Exist %backuppath%\DPMDB_03.* ren %backuppath%\DPMDB_03.* DPMDB_04.*
IF Exist %backuppath%\DPMDB_02.* ren %backuppath%\DPMDB_02.* DPMDB_03.*
IF Exist %backuppath%\DPMDB_01.* ren %backuppath%\DPMDB_01.* DPMDB_02.*
IF Exist %backuppath%\DPMDB.* ren %backuppath%\DPMDB.* DPMDB_01.*

ECHO. >> %LOGFILE%
copy %backupfile% %backuppath% /Y >> %LOGFILE%
GOTO END

:NOTEXIST
ECHO DPMSQL DB BACKUP does not exist!!! >> %LOGFILE%

:END
ECHO ===================================================================>> %LOGFILE%
ECHO. >> %LOGFILE%
ECHO. >> %LOGFILE%

Six copies will remain on this location. DPMDB.bak is the most recent DPM SQL Backup and DPMDB_05.bak is the oldest backup file.

1 comment:

  1. Hey Matthijs! Thanks for sharing the script I think it'll come in handy. Isn't it too much to clear the DPM to a disc on a daily bases? Do you really think it's necessary and that once every 2 days won't suffice? Thanks!

    ReplyDelete