IMPAX 6.5.1 Application Server Knowledge Base > Configuring and administering Active Directory authentication (ADAM) > Administering ADAM and AD LDS > Backing up AD LDS

Creating a scheduled AD LDS backup

To create scheduled AD LDS backups, create a PowerShell script that calls the Dsdbutil utility at regular intervals.

To create a scheduled AD LDS backup

  1. On the Windows Server 2008, Application Server, login as Administrator.

  2. Install the PowerShell feature.

    1. Select Administrative Tools > Server Manager > Features > Add Features.

    2. When the Add Features Wizard screen is displayed, enable Windows PowerShell. Click Next.

    3. On the Confirm Installation Selections screen, click Install.

      PowerShell is intalled.

  3. Create a PowerShell script (such as c:\mvf\bin\backupADLDS.bat) with the following content:

    $date = Get-Date -Format yyyy-MM-dd
    $backpath = “C:\ADLDSBackup\$date”
    $numberOfBackupsToKeep = 7
    $numberOfBackups = 0
    
    
    if (Test-Path "$backpath")
    {
    Write-Host "Backup has already been done today."
    }
    #Create a backup of the ADLDS instance
    else
    {
    New-Item "$backpath" -type directory
    $cmd = $env:SystemRoot + “\system32\dsdbutil.exe `”ac i AgfaHealthcare`” ifm `”create full $backpath`” q q”
    Invoke-Expression $cmd
    }
    
    
    $numberOfBackups = @(Get-ChildItem C:\ADLDSBackup\)
    $numberOfBackups = $numberOfBackups.Count
    
    Write-Host "Number of backups: $numberOfBackups"
    if ($numberOfBackups -gt $numberOfBackupsToKeep)
    {
    Write-Host "Deleting oldest backup(s) ..."
    $foldersToDelete = $numberOfBackups - $numberOfBackupsToKeep
    Get-ChildItem C:\ADLDSBackup\ | Sort-Object CreationTime | Select-Object -first $foldersToDelete | Remove-Item -recurse
    }
    else
    {
    Write-Host "Maximum allowed copies $numberOfBackups/$numberOfBackupsToKeep not yet exceeded."
    }
    
  4. To configure the directory path (destination), manually modify the $backpath value at the top of the script.

  5. To configure the number of stored backups, manually modify the $numberOfBackupsToKeep at the top of the script.

  6. Save the PowerShell script as:

    backupADLDS.ps1

  7. Create a new scheduled task that runs the PowerShell script at the frequency required.

    1. Select Start > Administrative Tools > Task Scheduler.

    2. From the Actions panel, select Create Basic Task.

    3. On the Create a Basic Task Wizard name field, type the task name. Click Next.

    4. On the Task Trigger screen, select when do you want the task to start. Click Next.

    5. On the screen of the selected task trigger, select the inteval you want the task to run. Click Next.

    6. On the Action screen, select Start a program. Click Next.

    7. On the Start a Program screen, in the Program/script field, type

      powershell.exe.

    8. In the Add arguments field, type the location of the script. For example:

      c:\mvf\bin\backupADLDS.ps1

    9. Click Next.

    10. On the Summary screen, click Finish.

      You have created a task to run the PowerShell script.

      By creating the scheduled task, the AD LDS instance data and logs are backed-up regularly in time stamped subdirectories, under c:\ADLDSBackup (for example, c:\ADLDSBackup\2011-11-02).


See also


Topic number: 120672

Applies to: IMPAX 6.5.1 Application Server Knowledge Base