none
Pre and Post Backup Script to Stop/Start VM RRS feed

  • Question

  • Anyone know how to configure DPM to stop a hyper-v guest OS before it is backed up, then start the vm after backup completes? 

    I have DPM agent installed on hyper-v host and trying to take a VM-level backup of a guest machine. On the hyper-v host, i have a powershell script file C:\scripts\stop-vm.ps1 that has one line "stop-vm -name <vmName>" and another script C:\scripts\start-vm.ps1 that has one line "start-vm -name <vmName>". 

    I've configured this file on the hyper-v host: 

    "c:\Program Files\Microsoft Data Protection Manager\DPM\Scripting\ScriptingConfig.xml"

    with the following settings:

    My "DataSourceName" is same as what's shown in DPM Console ("RCT\<vmName>"):

    But the script doesn't appear to be running because the VM is not shutting down before backups start. 


    Shaun

    Tuesday, November 12, 2019 5:28 PM

Answers

  • Hi Shaun,

    You need to get the component name for the VM and use that in the ScriptingConfig.xml because that is what DPM uses for the data source name since the VM-NAME can be changed on Hyper-V.

    To get the component name, run this SQL query on the DPM Server against the DPMDB name.  If the Hyper-V server is 2016 / 2019 and using RCT - then put in the vmname before running the script.

    use dpmdb  -- change name accordingly
    select ComponentName,caption from tbl_RM_RecoverableObject
    where Caption like cast ('%line%' as ntext) or
    Caption like cast ('%Backup Using%' as ntext) or
    Caption like cast ('%vmname%' as ntext)  -- specific VM if hosted on Hyper-V 2016 / 2019 and using RCT
    order by cast (Caption as nvarchar)

    That will return a list of the VM's componentname and caption.

    ComponentName                                        caption
    14E1E8B7-D4EF-4A7E-87F9-5DE04BCBA5BB vmname
    9F2A0C58-2AF2-4492-B121-120D97ADFCCB Offline\Accounts-domain
    FC80E789-2810-40E1-890D-DA9D2E785DB9 Offline\AODC1
    71E70E8F-D315-42D2-AE31-337FAF533A90 Offline\AOISCI

    Now use the ComponentName in the XML as seen below.

     <DatasourceScriptConfig DataSourceName="14E1E8B7-D4EF-4A7E-87F9-5DE04BCBA5BB">

    That should work.

    Regards
    Mike Jacquet


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, December 12, 2019 8:25 PM
    Moderator

All replies

  • Hi,

    Unfortunately you cannot achieve this from within DPM itself, you can however achieve this with scripting / automation by using the DPM & Hyper-V PowerShell cmdlets.

    DPM PowerShell reference

    Hyper-V PowerShell reference


    Best regards,
    Leon


    Blog: https://thesystemcenterblog.com LinkedIn:

    Tuesday, November 12, 2019 6:01 PM
  • Hi,

    Just checking to see if you have any update on your issue?

    If your issue was resolved, may I ask you to mark all the answers that helped you? This way it will also help others in the future who face the same challenge. Many thanks in advance!


    Best regards,
    Leon

    Blog: https://thesystemcenterblog.com LinkedIn:

    Wednesday, December 11, 2019 9:35 PM
  • I never did figure out a solution. 

    Shaun

    Thursday, December 12, 2019 6:36 PM
  • Hi Shaun,

    You need to get the component name for the VM and use that in the ScriptingConfig.xml because that is what DPM uses for the data source name since the VM-NAME can be changed on Hyper-V.

    To get the component name, run this SQL query on the DPM Server against the DPMDB name.  If the Hyper-V server is 2016 / 2019 and using RCT - then put in the vmname before running the script.

    use dpmdb  -- change name accordingly
    select ComponentName,caption from tbl_RM_RecoverableObject
    where Caption like cast ('%line%' as ntext) or
    Caption like cast ('%Backup Using%' as ntext) or
    Caption like cast ('%vmname%' as ntext)  -- specific VM if hosted on Hyper-V 2016 / 2019 and using RCT
    order by cast (Caption as nvarchar)

    That will return a list of the VM's componentname and caption.

    ComponentName                                        caption
    14E1E8B7-D4EF-4A7E-87F9-5DE04BCBA5BB vmname
    9F2A0C58-2AF2-4492-B121-120D97ADFCCB Offline\Accounts-domain
    FC80E789-2810-40E1-890D-DA9D2E785DB9 Offline\AODC1
    71E70E8F-D315-42D2-AE31-337FAF533A90 Offline\AOISCI

    Now use the ComponentName in the XML as seen below.

     <DatasourceScriptConfig DataSourceName="14E1E8B7-D4EF-4A7E-87F9-5DE04BCBA5BB">

    That should work.

    Regards
    Mike Jacquet


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, December 12, 2019 8:25 PM
    Moderator