Schedule backups of your AD LDS instance using Dsdbutil [2]

By | April 21, 2009

In my last post, I provided a small batch file to support scheduled IFM dumps of an AD LDS instance.  Afterwards, I realised that batch files are sooo last century and decided to have a crack at the Powershell version.  I’m no Bwandon, but the script below seems to do the trick.

#
# Name: Create_IFM_Dump.ps1
# Author: Tony Murray
# Version: 1.0
# Date: 20/04/2009
# Comment: PowerShell script to create AD LDS IFM
# backup.  To be run nightly as a scheduled task.
#
#########################################################

# Declare variables$IFMDir = “c:\backup\adlds\Instance1”
$IFMName = “adamntds.dit”
$cmd = $env:SystemRoot + “\system32\dsdbutil.exe”
$flags = “`”ac i Instance1`” ifm `”create full c:\backup\adlds\Instance1`” q q”
$date = get-Date -f “yyyymmdd”
$backupfile = $date + “_adamntds.bak”
$DumpIFM = “{0} {1}” -f $cmd,$Flags

# Main

# Create the folder if it doesn’t exist if(test-path -path $IFMDir)
{write-host “The folder” $IFMDir “already exists”}
else
{New-Item $IFMDir -type directory}
# Clear the IFM folder (Dsdbutil needs folder to be empty before writing to it) Remove-Item $IFMDir\*

# Run Dsdbutil.exe to create the IFM dump file Invoke-expression $DumpIFM# Rename the dump file to give the backup a unique name

rename-item $IFMDir”\”$IFMName -newname $backupfile

# End Main

 Tony

5 thoughts on “Schedule backups of your AD LDS instance using Dsdbutil [2]

  1. Pingback: EnterpriseAdmins.org » Blog Archive » Directory partition has not been backed up [DC=virtualcenter,DC=vmware,DC=int]

  2. tree

    I have given the user account access to the local “Backup Operators” but script will not run as a scheduled task.

    If I run it manually logged in with said user account the dsdbutil backs up the adamntds.dit file within seconds.

    Any suggestions?

    Reply
  3. Brandi G

    This was really helpful and I appreciate you sharing it. It saved me a lot of time. One small error I noticed, which is not a huge deal, is that the references to months in the date should be MM not mm. ($date = get-Date -f “yyyymmdd” should be yyyyMMdd) Otherwise you will get minutes.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.