Making a Snapshot of the Active Directory Database for Backup
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:
- Create a snapshot of the system partition
- Mount the snapshot
- Copy Windows/NTDS/ntds.dit to a new location
- Unmount the snapshot
- Delete the snapshot
- 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.
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.
Please leave your comments and suggestions on the discussion page.