Blog Post

System Center Blog
2 MIN READ

How to use a pre-backup or post-backup script to reset the archive bit in System Center Data Protection Manager

System-Center-Team's avatar
System-Center-Team
Former Employee
Feb 15, 2019
First published on TECHNET on Oct 13, 2010

Here's a good tip you might find handy.  Let's say you have a situation where you have a legacy application or some other need that requires the archive bit to be reset for data which is being backed up. Given the fact that DPM does not use the Archive bit but instead uses the USN Change journal you will have to accomplish this using a Pre-Backup or Post-Backup script.

In the following example I use a Post-Backup script to set the Archive bit on all the files in C:\DataDirectory recursively after the backup is done:

1. Edit the "%programfiles%\Microsoft Data Protection Manager\DPM\Scripting\ScriptingConfig.xml" to have the following contents on the Protected Server:

<?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:\DataDirectory">
<PostBackupScript>"C:\SetAcrhiveBit.cmd"</PostBackupScript>
<TimeOut>30</TimeOut>
</DatasourceScriptConfig>
</ScriptConfiguration>

2. Create a script in C:\SetAcrhiveBit.cmd locally on the Protected Server to have the following contents:

cd /d C:\DataDirectory
attrib  /S  +A      *

That's it!

Please note that the "DataSourceName" attribute in the ScriptingConfig.xml must match the name of the datasource as displayed in the DPM Administrative Console. In addition, if you have multiple datasources on a protected server which require a Pre/Post backup script then you must make additional entries in the ScriptingConfig.xml file using the XML blob as shown above with spaces between each and pay careful attention to specify the correct name for the datasource in the "DataSourceName" attribute as well as the "PostBackupScript" or "PreBackupScript" attribute to point to the correct location of the script which needs to be executed.

Note: This applies to DPM 2007 as well as DPM 2010.

For more information about how to use pre-post scripts for different data-sources please see the following TechNet documentation:

http://technet.microsoft.com/en-us/library/bb808870.aspx

Tyler Franke | Senior Support Escalation Engineer

The App-V Team blog: http://blogs.technet.com/appv/
The WSUS Support Team blog: http://blogs.technet.com/sus/
The SCMDM Support Team blog: http://blogs.technet.com/mdm/
The ConfigMgr Support Team blog: http://blogs.technet.com/configurationmgr/
The OpsMgr Support Team blog: http://blogs.technet.com/operationsmgr/
The SCVMM Team blog: http://blogs.technet.com/scvmm/
The MED-V Team blog: http://blogs.technet.com/medv/
The DPM Team blog: http://blogs.technet.com/dpm/
The OOB Support Team blog: http://blogs.technet.com/oob/
The Opalis Team blog: http://blogs.technet.com/opalis

Updated Mar 11, 2019
Version 4.0

1 Comment

  • Ernst_te_Brake's avatar
    Ernst_te_Brake
    Copper Contributor

    I hope i don't violate the rules but i try to find out bassed on your article how to get Pre-backup and Post-backup scripts for DPM to work in my enviroment, via scriptconfig.xml.

     

    I use System Center 2019 DPM version 10.19.577.0

     

    I have a hyper-v cluster of 3 servers, where on each server about 10 vms are running. For the vm who is running oracle i want run a pre backup script so the oracle database is clossed before i make a backup. I have a protection group with only that oracle vm in it and want to use scriptingconfig.xml when that protection group runs to run a batch file to stop the database.

    I made a test-begin.cmd and test-eind.cmd script that only echo the current date and time to a txt-file and placed it at a test dir on the vm.

    I made a protection group named ernst01 and selected only the c-drive of server01.

    When i do a "perform a consistency check" it failes with the message "The configuration of the pre-backup script or the post-backup script XML for volume c:\ is incorrect. (ID 30193: Details internal error code: 0x809909F4)". But i do not know what the xml error means.

    The scriptingconfig.xml looks like this:

    <?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:\test\test-begin.cmd </PreBackupScript>
            <PostBackupScript>c:\test\test-eind.cmd </PostBackupScript>
            <TimeOut>30<\TimeOut>
        </DatasourceScriptConfig>
    </ScriptConfiguration>

    the batch file looks like this:

    set now=%date:~-4%%date:~7,2%%date:~4,2%-%time%
    
    echo begin gelukt %now% >>c:\test\test.log

    I tried changing the c: into c:\ and c with and without various quotes but no change in the error. NOTE: also if i change it to pipotheclown it keep giving the error. I tried using " and ' and none around the c:\test....cmd. But nothing what i do seems to change the error.

    NOTE: When i completly remove the DatasourceScriptConfig then the "perform consistancy check" runs without errors

    Hope someone can help me with what i do wrong.