Making a Snapshot of the Active Directory Database for Backup

From Nikoforge Wiki
Jump to: navigation, search

The Active Directory database is stored in the ntds.dit file (NT Directory Services.Directory Information Tree). This file cannot be copied out of a running system. The only way to do this is to create a snapshot of the system partition using the ntdsutil program and then copy ntds.dit from there. In detail the followings steps are necessary:

  1. Create a snapshot of the system partition
  2. Mount the snapshot
  3. Copy Windows/NTDS/ntds.dit to a new location
  4. Unmount the snapshot
  5. Delete the snapshot
  6. Back up the copied ntds.dit file with Affa

This Windows batch file does the job. Additionally it saved the rsnycd config and the script itself.

Note-icon.gif Note:
The script requires a basic Cygwin environment installed.

REM unmount all mounted snapshots if any
ntdsutil snapshot "list all" "unmount *" quit quit
REM delete all existing snapshots if any
ntdsutil snapshot "list all" "delete *" quit quit
REM create a new snapshot
ntdsutil snapshot "activate instance ntds" create quit quit
REM mount the snapshot
ntdsutil snapshot "list all" "mount 1" quit quit
REM make the Backup Directory
/cygwin/bin/mkdir -p /cygdrive/c/Backup
REM copy ntds.dit to the Backup Directory
/cygwin/bin/cp -a /cygdrive/c/*SNAP*/WINDOWS/NTDS/ntds.dit /cygdrive/c/Backup/
REM copy the rsyncd config and this script to the Backup Directory
/cygwin/bin/cp -a /cygdrive/c/cygwin/etc/rsyncd.secrets /cygdrive/c/Backup/
/cygwin/bin/cp -a /cygdrive/c/cygwin/etc/rsyncd.conf /cygdrive/c/Backup/
/cygwin/bin/cp -a /cygdrive/c/ad-backup.bat /cygdrive/c/Backup/
REM unmount and delete the snapshot
ntdsutil snapshot "list all" "unmount *" quit quit
ntdsutil snapshot "list all" "delete *" quit quit

Store this script as C:\ad-backup.bat and run it from the Windows Task Scheduler.

User comments

Please leave your comments and suggestions on the discussion page.


Personal tools
Namespaces
Variants
Actions
Navigation
Category cloud