~ Mike Jacquet
Hello, Mike Jacquet here, and today I’d like to discuss several options to help you adequately protect the DPM SQL database in the event of physical or logical corruption, DPM/SQL Server failure, disk failure or site disaster.
The database for System Center 2012 Data Protection Manager (DPM 2012) contains all the information that you see when you open the DPM console and lots of information you do not see that allows DPM to function. For the most part, you can rebuild a DPM server from scratch and be back in business if you have a recent backup copy of the DPM database. Tape based backups would be accessible and all protection group settings and backup schedules would be maintained. If the DPM storage pool disks were not affected by the outage then the disk-based backups would also be usable after a rebuild.
Making a backup of the DPM database using DPM itself seems to be some sort of oxymoron as you ask yourself “Wait, if DPM is down, how can I restore the database?” However, with a little preplanning there are several obvious and some not so obvious options that make it easy to recover a DPM backup of the DPM database.
Here are the backup options I would like to discuss in detail and offer pros and cons of each. You can chose to use more than one option for added protection.
1. Using DPM to back up the DPMDB to DPM storage pool.
2. Using DPM to back up the DPMDB to tape.
4. Using DPM to back up the DPMDB to Azure using online backup.
6. Using DPMBACKUP -DB to make backup of DPMDB.
7. Use Native SQL Server backup and not use DPM for backup at all.
How to restore a DPMDB from a recent backup
Using DPM to back up the DPMDB to DPM storage pool
- Pro - Easily configured and monitored in DPM.
- Pro – DPM scheduled backups support 512 express full backups. If done hourly, this provides 21 days of short term protection. If done every 30 minutes, it provides 10 days of protection.
- Pro - The backup is kept on DPM storage pool disks and is locally accessible.
- Con - Not a good option for disaster recovery. DPM Server or DPM storage pool disk failure may hinder recovery efforts.
- Con - Not an option if the DPM DB is hosted locally and you want to enable secondary protection. A workaround would be to use a remote SQL Server to host the DPMDB.
- Con - Some preparation and special steps are required to gain access to the recovery points if the DPM service or console is non-operational.
Preparation Before Failure
A) You will need to know the DPM Replica volume Mount point path or Volume GUID beforehand so you know what volume holds the DPMDB backup. You can use the SQL script below to extract that information any time after initial protection but before the need to restore. Save the information in a safe place so that it is easily obtainable should a disaster occur. Note that you will need to replace %dpmsqlservername% with the name of the SQL Server hosting the DPMDB.
Select ag.NetbiosName as
ServerName,ds.DataSourceName,vol.MountPointPath,vol.GuidName
from tbl_IM_DataSource as ds
join tbl_PRM_LogicalReplica as lr on ds.DataSourceId=lr.DataSourceId
join tbl_AM_Server as ag on ds.ServerId=ag.ServerId
join tbl_SPM_Volume as vol on lr.PhysicalReplicaId=vol.VolumeSetID
and vol.Usage =1 -- Replica=1, DiffArea=2
and lr.Validity in (1,2)
where ds.datasourcename like '%dpmdb%'
and servername like '%dpmsqlservername%' --netbios name of server hosting DPMDB
Here is sample output from this query:
B) You will need a copy of psexec.exe from here on the DPM Server.
How to Recover
Assuming the DPM server itself is still operational and the storage pool is intact but the DPM service or console has problems, use the following steps to copy the DPMDB from the Replica volume or a shadow copy.
A) Decide from which time you want to recover the DPMDB database.
1. If you want to copy the DPMDB from the last backup taken directly off of the DPM Replica volume, use mountvol.exe to assign a drive letter to the replica volume using the guid from the SQL script output. For example:
C:\Mountvol X: \\?\Volume{d7a4fd76-a0a8-11e2-8fd3-001c23cb7375}\
2. If you want to copy the DPMDB from a previous recovery point (Shadow copy) then you need to list all the shadow copies for the replica using the volume GUID from the SQL script output. The command below will list all the shadow copies for that volume.
C:\>Vssadmin list shadows /for=\\?\Volume{d7a4fd76-a0a8-11e2-8fd3-001c23cb7375}\
Note the creation time and the Shadow Copy ID you want to recover from. Here is an example from my computer:
C:\Windows\system32>vssadmin list shadows /for=\\?\Volume{d7a4fd76-a0a8-11e2-8fd3-001c23cb7375}\vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
(C) Copyright 2001-2013 Microsoft Corp.
Contents of shadow copy set ID: {7c67f31b-9b5b-45fc-8c9c-3688cce6bc87}
Contained 1 shadow copies at creation time: 7/1/2014 8:00:03 PM
Shadow Copy ID: {9f521455-dd96-4a80-8ad0-b5b1892c2f31}
Original Volume: (C:\Program Files\Microsoft DPM\DPM\Volumes\Replica\SqlServerWriter\vol_850b95be-b942-4351-83bd-0a1815a936b2\)\\?\Volume{d7a4fd76-a0a8-11e2-8fd3-001c23cb7375}\
Shadow Copy Volume: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy162
Originating Machine: lc2-dpmlib2.Contoso.com
Service Machine: lc2-dpmlib2.Contoso.com
Provider: 'Microsoft Software Shadow Copy provider 1.0'
Type: DataVolumeRollback
Attributes: Persistent, No auto release, No writers, Differential
Contents of shadow copy set ID: {c23c0987-4ebe-462f-9bd4-c90ffbefc725}
Contained 1 shadow copies at creation time: 7/2/2014 8:00:02 PM
Shadow Copy ID: {ad959229-4f9f-43ce-8c84-014fdbf81a08}
Original Volume: (C:\Program Files\Microsoft DPM\DPM\Volumes\Replica\SqlServerWriter\vol_850b95be-b942-4351-83bd-0a1815a936b2\)\\?\Volume{d7a4fd76-a0a8-11e2-8fd3-001c23cb7375}\
Shadow Copy Volume: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy164
Originating Machine: lc2-dpmlib2.Contoso.com
Service Machine: lc2-dpmlib2.Contoso.com
Provider: 'Microsoft Software Shadow Copy provider 1.0'
Type: DataVolumeRollback
Attributes: Persistent, No auto release, No writers, Differential
Now use diskshadow.exe to mount the shadow copy to an unused drive letter X: using the shadow copy ID so you can copy the DPMDB files. Here’s an example:
C:\>diskshadow.exeMicrosoft DiskShadow version 1.0Copyright (C) 2013 Microsoft CorporationOn computer: LC2-DPMLIB2, 7/3/2014 4:31:42 PMDISKSHADOW> expose {ad959229-4f9f-43ce-8c84-014fdbf81a08} X:The shadow copy was successfully exposed as X:\.DISKSHADOW> exit
B) Open an administrative command prompt and run psexec.exe -s cmd.exe to start a command prompt in system context so you have permissions to navigate the replica volume (X:) to copy out the files.
C:\>psexec.exe -s cmd
PsExec v1.96 - Execute processes remotely
Copyright (C) 2001-2009 Mark Russinovich
Sysinternals - www.sysinternals.com
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Windows\system32>
Now CD to the X: drive and navigate down to the location of DPM SQL database files and copy them to a location that is easy to restore from.
2 file(s) copied.
C) After the copy is complete, exit the psexec cmd window, then run diskshadow.exe and unexposed the x: volume.
C:\>Diskshadow.exe
DISKSHADOW> unexpose X:
Shadow copy ID {ad959229-4f9f-43ce-8c84-014fdbf81a08} is no longer exposed.%DPMDB
D) You can now restore the DPMDB files using SQL Management Studio or DPMSYNC -RESTOREDB commands.
Using DPM to back up the DPMDB to tape
- Pro - Easily configured and monitored in DPM.
- Pro – DPM scheduled tape backups support retention up to 99 years.
- Pro - Tape backup can be taken offsite for disaster recovery.
- Pro - Tape backup can be restored from any other DPM server that has a tape drive/library attached that uses the same tape media type.
- Pro - Tape can be encrypted for secure storage.
- Con - Not an option if the DPM DB is hosted locally and you want to enable secondary protection. Workaround would be to use a remote SQL Server to host the DPMDB.
- Con - Only one tape backup per day can be scheduled.
- Con - Need a working DPM server with a tape library to be able to read a DPM backup tape that contains the copy of the database you want to restore.
- Con - Some preparation and special steps are required to gain access to the tape based recovery points.
Preparation Before Failure
You will need to know the barcode or tape labels of the tapes that contain a copy of the DPM database. The best way to accomplish that is to schedule a Status Report to be mailed on the same day that the DPM database is backed up. The report will include the last backup date/time, the tape label and the barcode so that you can locate it for recovery.
You can also use the SQL script below to extract the information from the current database so you can to store it separately in case of disaster.
Select Path,ro.FileSpec,media.Label,media.BarcodeValue,pd.CreationDate,
pd.ExpiryDate,pd.LifeStatus as "1=valid, 2=expired"
from dbo.tbl_MM_MediaMap mm
join dbo.tbl_MM_PhysicalDataset pd on pd.datasetid = mm.datasetid
join dbo.tbl_MM_Media media on media.MediaId = mm.MediaId
join dbo.tbl_RM_RecoverableObjectFileSpec ro on ro.DatasetId = mm.DatasetId
where ro.filespec like '%DPMDB%'
order by CreationDate desc
Sample output from the SQL query above:
How to Recover
This may take a little bit of pre-planning depending on the tape hardware available at the time as well as the current state of the DPM server that took the tape-based backup. If you cannot restore the tape backup from the DPM server that took the backup, you will need to restore it from another DPM server that has the same type of tape drive so the tape can be read. You may have to rebuild the DPM server if the only tape hardware available was the one attached to the failed DPM server. In any case, the restoration steps will be the same.
IMPORTANT! If you are using DPM tape encryption, you will need the same certificate used to encrypt the tape installed on the alternate DPM server.
A) Locate the physical tape that contains the version/date-time of the DPM database you want to restore.
B) Insert the backup tape into the tape drive or library and perform a detailed inventory in the DPM console under Management –> Libraries.
NOTE If the DPM server you are restoring from is a different DPM server, or it is a new installation of DPM on the original server, the tape will be shown as imported, meaning it was not created by this DPM server.
C) If necessary, recatalog the imported tape.
D) On the recovery tab, locate the DPMDB data source. If it was from an imported tape, the recovery point will be under the "External DPM tapes" tree.
E) Recover the DPMDB files. Depending on the circumstance, you can select to "Recover to any instance of SQL Server" or "Copy to a network folder".
F) Once the files are restored from tape, continue with recovery steps using SQL Management Studio or DPMSYNC -RESTOREDB commands.
Using Native SQL Server backup to back up the DPMDB to a share, and have DPM protect the share using disk-to-disk protection
- Pro - Easily monitored in DPM.
- Pro - Multiple locations of the backup database files.
- Pro - Easily accessible from any Windows machine on the network.
- Pro - Potentially the fastest recovery method.
- Con - Only supports 64 recovery points.
Con - Not a good option for site disaster recovery. DPM server or DPM storage pool disk failure may hinder recovery efforts. - Con - Not an option if the DPM DB is hosted locally and you want to enable secondary protection. A workaround would be to use a remote SQL Server to host the DPMDB.
- Con - Some extra preparation is needed to get it configured and tested.
- Con - Some extra preparation and recovery time is needed should the DPM server itself be down but DPM storage pool disks are fine.
Required Initial Setup Steps
This option is one of my favorites since recovery can potentially be the easiest and fastest of all the other options. We are leveraging native OSQL utility to make the DPM database backup and Windows VSS previous versions to facilitate the restore.
NOTE This works best if you enable DPM End User Recovery but it is not required.
A) If the SQL Server hosting the DPMDB is a remote SQL Server, install a DPM agent on the remote SQL Server.
B) On the SQL Server hosting the DPM database, make a folder on a drive with enough free space to hold a single copy of a backup. In my example I chose C:\DPMBACKUP as the backup location and folder.
C) Share the C:\DPMBACKUP folder as DPMBACKUP.
D) Copy and paste the OSQL command below into Notepad and save it to a file named C:\DPMBACKUP\bkupdb.cmd. Make sure there is no .txt extension. Modify the SQL_Instance_name and DPMDB_NAME to match the instance and DPMDB name used by your DPM server.
OSQL -E -S localhost\SQL_INSTANCE_NAME -Q "BACKUP DATABASE DPMDB_NAME TO DISK='C:\DPMBACKUP\dpmdb.bak' WITH FORMAT"
E)Using Notepad, open the ScriptingConfig.xml file located under the ...\DPM\Scripting folder.
- This would be C:\Program Files\Microsoft Data Protection Manager\DPM\Scripting on a remote SQL server.
- This would be C:\Program Files\Microsoft System Center 2012 R2\DPM\DPM\Scripting on a DPM 2012 R2 server.
- This would be C:\Program Files\Microsoft System Center 2012\DPM\DPM\Scripting on a DPM 2012 or DPM 2012 SP1 server.
- This would be C:\Program Files\Microsoft DPM\DPM\Scripting on a DPM 2010 server or a DPM 2012 server that had been upgraded from DPM 2010.
F)Modify ScriptingConfig.xml and change DataSourceName= to be the drive letter that contains the DPMDBBACKUP folder/share. Change the PreBackupScript entry to the full path and name of the bkupdb.cmd saved in step D.
<?xml version="1.0" encoding="utf-8"?>
<ScriptConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.microsoft.com/2003/dls/ScriptingConfig.xsd">
<DatasourceScriptConfig DataSourceName="C:">
<PreBackupScript>C:\DPMDBBACKUP\bkupdb.cmd</PreBackupScript>
<TimeOut>120</TimeOut>
</DatasourceScriptConfig>
</ScriptConfiguration>G)Save the changes to ScriptingConfig.xml.
H) Protect the C:\DPMBACKUP folder or the \\sqlservername\DPMBACKUP share using DPM and wait for the initial replica to be created. There should be a dpmdb.bak in the C:\DPMBACKUP folder as a result of the pre-backup script running which was in turn copied to the DPM replica.
Optional steps to share out the DPMBACKUP folder on the replica if DPM End User Recovery (EUR) feature is not enabled.
A) In the DPM console under Protection, locate the DPMBACKUP data source and select it. In the details section, click on the link to the Replica Path that says "Click to view Details" and copy the path into Notepad. Remove the source path and retain the destination path. The path should look similar to the following:
C:\Program Files\Microsoft System Center 2012 R2\DPM\DPM\Volumes\Replica\File System\vol_c9aea05f-31e6-45e5-880c-92ce5fba0a58\454d81a0-0d9d-4e07-9617-d49e3f2aa5de\Full\DPMBACKUP
B) Make a share to that path using a sharename of DPMSERVERNAME-DPMDB. You can use the Net Share command below from an administrative command prompt.
Net Share DPMSERVERNAME-dpmdb="C:\Program Files\Microsoft System Center 2012 R2\DPM\DPM\Volumes\Replica\File System\vol_c9aea05f-31e6-45e5-880c-92ce5fba0a58\454d81a0-0d9d-4e07-9617-d49e3f2aa5de\Full\DPMBACKUP"
How to Recover
A) Connect to the \\DPMServer\DPMSERVERNAME-dpmdb share using Explorer from any Windows computer.
B) Right-click the dpmdb.bak file to view properties. On the Previous Versions tab will be listed all the backups that you can select and copy. There is also the very last backup still located in the C:\DPMBACKUP folder which is also easily accessible.
Preparation Before a Complete DPM Server Failure
If you need to move a SAN attached DPM storage pool disk to another server to be able to read from the replica volume, or to re-install Windows to read locally attached disks, you will need to know the DPM Replica volume Mount point path or Volume GUID beforehand so you know what volume holds the DPMDB backup. You can use the SQL script below to extract that information any time after initial protection but before the need to restore. Replace the %dpmsqlservername% with the name of the SQL Server hosting the DPMDB.
Select ag.NetbiosName as
ServerName,ds.DataSourceName,vol.MountPointPath,vol.GuidName
from tbl_IM_DataSource as ds
join tbl_PRM_LogicalReplica as lr on ds.DataSourceId=lr.DataSourceId
join tbl_AM_Server as ag on ds.ServerId=ag.ServerId
join tbl_SPM_Volume as vol on lr.PhysicalReplicaId=vol.VolumeSetID
and vol.Usage =1
and lr.Validity in (1,2)
where ds.datasourcename like '%C:\%' -- volume drive letter for DPMBACKUP
and servername like '%dpmsqlservername%' --netbios name of server hosting DPMDB
Sample Output from SQL query above:
How to Recover After Moving DPM Storage Pool Disks or a DPM Server Rebuild
A) Now that you have the volume GUID, should that volume need to be mounted on another Windows server or after a DPM server rebuild, use mountvol.exe to assign it a drive letter using the volume GUID from the SQL script output.
C:\Mountvol X: \\?\Volume{d7a4fd76-a0a8-11e2-8fd3-001c23cb7375}\
B) Re-share the DPMBACKUP folder on the replica volume using the drive letter and portion of the replica path representing the folder structure.
net share SERVERNAME-DPMDB="X:\454d81a0-0d9d-4e07-9617-d49e3f2aa5de\Full\DPMBACKUP"
C) Connect to the \\SERVERNAME\DPMSERVERNAME-dpmdb share using Explorer from any Windows computer.
D) Right-click the dpmdb.bak file to view the Properties. On the Previous Versions tab will be listed all the backups that you can select and copy.
Using DPM to back up the DPMDB to Azure using online backup
- Pro - Easily configured and monitored in DPM.
- Pro - Multiple locations of the backup database files.
- Pro - Cloud storage is excellent choice for Site Disaster Recovery.
- Pro - Most secure storage of DPMDB.
- Pro - Support 120 online recovery points.
- Con - This option is only available on DPM 2012 SP1 or later.
- Con - Requires Azure account and additional DPM configuration.
- Con - Slight cost for Azure storage.
- Con - Requires an alternate Windows Server 2012 based system with the Azure agent to gain access to DPM backups stored in the Azure backup vault. This cannot be another DPM server. You must also have the certificate used for the backup vault and know the same passphrase used on the DPM server from which you want to restore backups.
- Con - Not an option if the DPM DB is hosted locally and you want to enable secondary protection. A workaround would be to use a remote SQL Server to host the DPMDB.
- Con - Some extra preparation and recovery time.
- Con - Some Windows PowerShell commands are required so PS knowledge is helpful but not necessary.
This post will not cover setting up a backup vault and installing the Azure agent on the DPM server since that is covered in detail in the TechNet article below. Instead, I will concentrate on the steps necessary to restore a DPM backup from Azure backup vault using Windows PowerShell.
Back up DPM workloads to Azure (http://msdn.microsoft.com/en-us/library/azure/dn337332.aspx)
Preparation Before a Complete DPM Server Failure
If you need to recover a DPMDB backup from Azure storage, you will need to know the DPM replica volume Mount point path so that you know what recovery point has the DPMDB backup. You can use the SQL script below to extract that information any time after initial protection but before the need to restore. Save the information in a safe place that is easily accessible should a disaster occur. Replace %dpmsqlservername% with the name of the SQL Server hosting the DPMDB.
Select ag.NetbiosName as ServerName,ds.DataSourceName,vol.MountPointPath
from tbl_IM_DataSource as ds
join tbl_PRM_LogicalReplica as lr on ds.DataSourceId=lr.DataSourceId
join tbl_AM_Server as ag on ds.ServerId=ag.ServerId
join tbl_SPM_Volume as vol on lr.PhysicalReplicaId=vol.VolumeSetID
and vol.Usage =1
and lr.Validity in (1,2)
where ds.datasourcename like '%dpmdb%'
and servername like '%dpmsqlservername%' --netbios name of server hosting DPMDB
Sample Output from the SQL query above:
How to Recover
A) On any Windows 2008R2 / 2012 server that has internet access, install the Certificate and the Windows Backup Feature.
Note: This cannot be a server with DPM installed.B) Sign into the Windows Azure portal, and in Recovery Services under the backup vault, download the agent for Windows Server.
C) Install the Azure agent.
D) Launch Windows Azure backup - then register the server. (which requires the same certificate used on the failed DPM server you are attempting to restore.)
E) Once registered, open a Windows Power shell command window using administrative privileges.
The PowerShell commands below will detail a single recovery from a backup vault that has backups from two DPM servers. We will restore the latest DPMDB backup for LC2-DPMLIB2 from the backup vault.
Entries after # are my comments:
Using a Secondary DPM Server to back up the DPMDB of the Primary DPM Server and vice versa if desired. This is called Cyclic protection
- Pro - Easily configured and monitored in DPM.
- Pro – DPM scheduled backups support 512 express full backups. If done hourly, this provides 21 days of short term protection. If done every 30 minutes it provides 10 days protection.
- Pro - The backup is kept on the secondary DPM server storage pool disks which is locally accessible.
- Pro – A good disaster recovery solution if secondary DPM server is offsite.
- Con - Additional DPM server/storage required. Both DPM servers must to be running the same DPM version and update rollup.
Preparation Before Failure
A) On the Secondary DPM server under Management –> Agents, install the DPM agent on the server hosting the DPM SQL database. This may be a remote SQL Server or the primary DPM server itself. Once installed, the server should be shown under "Unprotected server with protection agents" and should show “OK” if refreshed.
B) Make a new protection group. Under Select group member, expand the resources under the server hosting the DPM database. Under All SQL Servers, select the DPM database to protect.
C) Select the protection type Disk or Tape, and optionally Online if supported.
D) Enter the short term goals. For disk, you can have 512 express full backups as often as every 30 minutes.
E) Finish the Protection Group Wizard. Protection is started once the initial recovery point is made.
How to Recover
Recovery should be very straight forward since you are recovering from a fully intact and running secondary DPM server. Recover the database like you would recover any other protected data source using the Recovery Wizard. You should always run DPMSYNC -SYNC after restoring a DPM database.
Using DPMBACKUP to back up the DPMDB
- Pro - Easy to run for instant ad-hoc backups
- Pro - Can be scheduled using Windows Task Scheduler to run as often as you like.
- Pro - The backup is kept on a local disk which is easily accessible.
- Pro - Totally Independent of DPM.
- Con - Not a good option for disaster recovery unless the backups are copied to a remote location.
- Con - By default the Dpmdb.bak file is overwritten each time dpmbackup.exe is run, so there will be no previous versions unless you rename it afterwards.
- Con - Requires local storage
Preparation Before Failure
The required switches for Dpmbackup.exe have changed after DPM 2012 SP1 and now support sharing a SQL instance between multiple DPM servers. If you have a mixture of DPM servers, Microsoft recommends using the full syntax in all cases to be sure the backups work. It is also recommended that you use a common local target location so that it is consistent across all DPM servers.
Recommended switches:
Dpmbackup.exe -db -instancename DPMINSTANCE -dpmdbname DPMDB_NAME -targetlocation C:\DPMDBBACKUPS
If the SQL Server is using the default instance (MSSQLSERVER) then the switches are:
Dpmbackup.exe -db -instancename (Local) -dpmdbname DPMDB_NAME -targetlocation C:\DPMDBBACKUPS
On a remote SQL server, the dpmbackup.exe utility is located in the SQLPREP folder under C:\Program Files\Microsoft Data Protection Manager\DPM201x (Where x is the version of DPM).
How to Automate
A) Open Notepad and copy/paste the script below, then save it to a file called backupdb.cmd on the server hosting the DPM database. Change the backupdir variable in the script to a local location to store the DPM database backups. Be sure there is adequate space for the frequency and duration of the backups based on the database size. You can enable NTFS compression on the target folder to help save space.
************* COPY BELOW ************
Echo off
Set backupdir=c:\DPMDBBACKUPS
cd %backupdir%
REM Build environment variables for current date, time to be used in backup command strings to create unique DPMDB.BAK names.
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l
for /f "Tokens=1-2 Delims=: " %%i in ('time /t') do set tm=%%i-%%j
set tm=%tm%
set dtt=%dt%-%tm%
REM Build environment variables for current day of the week.
REM
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set DAYOFWEEK=%%i
Dpmbackup.exe -db -instancename MSDPM2012 -dpmdbname DPMDB -targetlocation %backupdir% >DPMBACKUP-STATUS.TXT
if %errorlevel% NEQ 0 goto exit
Ren dpmdb.bak %DTT%-DPMDB.BAK
echo.>>DPMBACKUP-STATUS.TXT
echo last backup was on %date% at %time% >>DPMBACKUP-STATUS.TXT
REM Delete oldest backups
IF "%DAYOFWEEK%" == "Sun" goto Sun
IF "%DAYOFWEEK%" == "Mon" goto Mon
IF "%DAYOFWEEK%" == "Tue" goto Tue
IF "%DAYOFWEEK%" == "Wed" goto Wed
IF "%DAYOFWEEK%" == "Thu" goto Thu
IF "%DAYOFWEEK%" == "Fri" goto Fri
IF "%DAYOFWEEK%" == "Sat" goto Sat
:Sun
Del Mon*.bak
exit
:Mon
Del Tue*.bak
exit
:Tue
Del Wed*.bak
exit
:Wed
Del Thu*.bak
exit
:Thu
Del Fri*.bak
exit
:Fri
Del Sat*.bak
exit
:Sat
Del Sun*.bak
exit********** END COPY ABOVE **********
B) Using Windows Task Scheduler, schedule backupdb.cmd to run as often as you like.
C) Check that the backup files are created after the scheduled time. The batch file will keep as many backups as you schedule to run each day because the dpmdb.bak file is renamed using day-mm-dd-yyyy-hh-mm-dpmdb.bak. The script deletes the oldest backup files automatically after a week. After midnight, it deletes the oldest day’s backup (i.e. the first backup on Sunday will delete last Monday’s backups).
Use Native SQL Server backup and not use DPM for backup at all
- Pro - Built-in to SQL Server.
- Pro - Can be scheduled to run as often as you like.
- Pro - The backup is kept on a local disk which is easily accessible.
- Pro - Totally independent of DPM.
- Pro - Can schedule backup file cleanup.
- Con - Not a good option for disaster recovery unless the backups are copied to a remote location.
- Con - Requires local storage for backups which may limit retention and frequency.
Please see the following video that explains in detail how to schedule native SQL backups:
Setting up a Maintenance Plan to Backup Databases
How to restore a DPMDB from a recent backup using DPMSync.exe
This section details how to restore a DPM database backup using the DPMSync.exe utility. This utility supports restoring backups taken by DPM, Dpmbackup.exe and Native SQL backup. The utility can restore backups with the .bak extension or restore SQL database files with the .mdf and .ldf file extensions.
- Starting with DPM 2012, we added support for multiple DPM servers to share one instance of SQL Server for the DPM database.
- Starting with DPM 2012 R2, we added support to use clustered SQL Server nodes for its database.
Because of these two changes, there are more required parameters when restoring a DPM 2012 database using the DPMSync.exe utility.
The DPMSync.exe utility is installed by default in the DPM installation path inside the bin folder. However, this should already be added to the %path% system variable and can run from any administrative command prompt.
If the DPM database is being hosted on a remote SQL Server, including a SQL cluster, then DPMSync.exe can be found under C:\Program Files\Microsoft Data Protection Manager\DPM2012 (or DPM 2012 R2)\SQLPrep folder on the remote SQL Server.
Below are examples of Dpmsync.exe commands for various configurations.
RESTORE DPMDB ON REMOTE SQL SERVER
NOTE When using Default instance specify (local) or period (.) for the instance name.
C:\Program Files\Microsoft Data Protection Manager\DPM2012\SQLPrep>dpmsync -restoredb -dbloc c:\temp\dpmdb_dpm03.bak -instancename DPMSQLDB -dpmdbname dpmdb_dpm03
DpmSync 2.0 - DPM database synchronization command-line tool
Copyright (c) 2012 Microsoft Corporation. All rights reserved.
Restoring DPM Database completed.
RESTORING DPMDB ON LOCAL DPM SERVER USING .MDF FILE
C:\>dpmsync -restoredb -dbloc E:\MSDPM2012$DPMDB.mdf -instancename dpmserver\msdpm2012 -dpmdbname dpmdb
DpmSync 2.0 - DPM database synchronization command-line tool
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Copying file from 'e:\msdpm2012$dpmdb.mdf' to 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\DPMDB\MSDPM2012$DPMDB.mdf.recovered'
Copying file from 'e:\msdpm2012$dpmdb_log.ldf' to 'C:\Program Files\Microsoft System Center 2012\DPM\DPM\DPMDB\MSDPM2012$DPMDB_log.ldf.recovered'
Files copied successfully.
Database detached successfully.
Renamed file 'MSDPM2012$DPMDB.mdf.recovered' to 'MSDPM2012$DPMDB.mdf'
Renamed file 'MSDPM2012$DPMDB_log.ldf.recovered' to 'MSDPM2012$DPMDB_log.ldf'
Database attached successfully.
Restoring DPM Database completed.
NOTE Please be aware of the following issue when restoring using .mdf files to a database named other than DPMDB:
KB2968666 - Error ID: 470" when you run the dpmsync -restoredb command in Data Protection Manager (http://support.microsoft.com/kb/2968666)
Anytime a DPMDB is restored from a backup you need to run the DpmSync -Sync command to reconcile backup job run times, DPM storage pool usage and other configuration settings that may have changed since the restored database backup time. The DPMSYNC -SYNC command must be run on the DPM server where it has access to the storage pool and VS snapshots. A Consistency Check will be required on all data sources before normal protection can be resumed.
On the DPM Server, run the following:
C:\>dpmsync –sync
DpmSync 2.0 - DPM database synchronization command-line tool
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Note: The DPM role configuration of this server will also be rolled back during this operation.
DPM Synchronization completed.
Your tape library status may have changed.
Recommendation: Go to the Library tab in the Management Task Area of the DPM Administration Console and choose the Inventory Library action.
I hope you found this post useful and encourages you to take frequent DPM DB backups to protect your DPM server from logical or physical DPMDB corruption or loss.
Mike Jacquet | Senior Support Escalation Engineer | Microsoft GBS Management and Security Division
Get the latest System Center news onFacebookandTwitter:
System Center All Up: http://blogs.technet.com/b/systemcenter/
System Center – Configuration Manager Support Team blog: http://blogs.technet.com/configurationmgr/
System Center – Data Protection Manager Team blog: http://blogs.technet.com/dpm/
System Center – Orchestrator Support Team blog: http://blogs.technet.com/b/orchestrator/
System Center – Operations Manager Team blog: http://blogs.technet.com/momteam/
System Center – Service Manager Team blog: http://blogs.technet.com/b/servicemanager
System Center – Virtual Machine Manager Team blog: http://blogs.technet.com/scvmm
Windows Intune: http://blogs.technet.com/b/windowsintune/
WSUS Support Team blog: http://blogs.technet.com/sus/
The AD RMS blog: http://blogs.technet.com/b/rmssupp/
MED-V Team blog: http://blogs.technet.com/medv/
Server App-V Team blog: http://blogs.technet.com/b/serverappv
The Forefront Endpoint Protection blog : http://blogs.technet.com/b/clientsecurity/
The Forefront Identity Manager blog : http://blogs.msdn.com/b/ms-identity-support/
The Forefront TMG blog: http://blogs.technet.com/b/isablog/
The Forefront UAG blog: http://blogs.technet.com/b/edgeaccessblog/