Schedule IDOL Backups with Task Scheduler and PowerShell

Today we are looking at an alternative way to backup the IDOL content engines. Using Task Scheduler and Powershell, we can add some useful functionality into our backup routines.

The “out of the box” backup method requires you to set a section in each config file with various parameters. This method works well but it does present some challenges around planned interruptions and reporting. What if you want to skip the backups this weekend because of a maintenance window? What if you want a log file of just the backups or an email notification upon completion / failure? In addition to the backups, you also need to copy .cfg and .db files. Let’s make things a little easier and combine all of these into one step!

If you’ve never used PowerShell before, it can be overwhelming at first. However, after some quick study, I think you’ll quickly find that it is capable of so much that you’ll soon be using it for most of your administration and automation tasks (yes…really…). If you’ve never run PowerShell on the IDOL server(s) before, you’ll need to open it up and set the execution policy to unrestricted. This allows scripts to be run on that machine from now on. The syntax is: Set-ExecutionPolicy Unrestricted -Scope LocalMachine

Now, let’s breakdown the actual script that we will use to perform the backups. This script assumes that we will be backing up 3 content engines. It also assumes that we are backing up every week, and only keeping the latest version of the backup since index time is so quick. The completed script looks like this:

#
# PS Script to Backup IDOL
# Created By JB Trexler
# Created On: 11/4/2011
#
# Description:
# This was written to backup the IDOL Config and database files.
# It will also launch the command to backup the collections via the web browser (silently)
#
# Define Directory Variables
 $IDOLDeployDir = "E:\Program Files\Autonomy\Indexer"
 $ConfigBAKDir = "J:\IDOLBAK\ConfigFiles"
 $IDOLCEBakDir1 = "J:\IDOLBAK\CE1"
 $IDOLCEBakDir2 = "J:\IDOLBAK\CE2"
 $IDOLCEBakDir3 = "J:\IDOLBAK\CE3"
# Declare IE as an object for each content engine that you need to backup.
 $ie1 = new-object -com internetexplorer.application
 $ie2 = new-object -com internetexplorer.application
 $ie3 = new-object -com internetexplorer.application
# Copy the Config and db files
 Copy-Item $IDOLDeployDir\*.cfg $ConfigBAKDir -recurse
 Copy-Item $IDOLDeployDir\*.db $ConfigBAKDir -recurse
# Remove Existing Backups
 Remove-Item $IDOLCEBakDir1\* -recurse
 Remove-Item $IDOLCEBakDir2\* -recurse
 Remove-Item $IDOLCEBakDir3\* -recurse
# Silently Launch IE to Backup the Directories
 $ie1.navigate("http://localhost:11001/DREBackup?"+$IDOLCEBakDir1)
 $ie1.visible = $false
 $ie2.navigate("http://localhost:12001/DREBackup?"+$IDOLCEBakDir2)
 $ie2.visible = $false
 $ie3.navigate("http://localhost:13001/DREBackup?"+$IDOLCEBakDir3)
 $ie3.visible = $false
# All Done
 Write-Host "Backups Issued.  Monitor the index log file of each content engine for completion status."

Save that file as IDOLBackups.ps1

The next Script is a variation on the first. This is designed to run the DRECOMPACT operation as a scheduled task. The completed script looks like this:

#
# PS Script to Compact IDOL
# Created By JB Trexler
# Created On: 11/4/2011
#
# Description:
# This was written to Compact the IDOL Content Engines.
# It will launch the command to compact the collections via the web browser (silently)

# Declare IE as an object for each content engine that you need to backup
$ie1 = new-object -com internetexplorer.application
$ie2 = new-object -com internetexplorer.application
$ie3 = new-object -com internetexplorer.application

# Silently Launch IE to Backup the Directories
$ie1.navigate("http://localhost:11001/DRECOMPACT")
$ie1.visible = $false
$ie2.navigate("http://localhost:12001/DRECOMPACT")
$ie2.visible = $false
$ie3.navigate("http://localhost:13001/DRECOMPACT")
$ie3.visible = $false

# All Done
Write-Host "DRECOMPACT Issued. Monitor the index log file of each content engine for completion status."

Save that file as IDOLCompact.ps1

From here, you can Schedule a Task to run both of these jobs in Task Scheduler. Keep in mind that the DRECOMPACT operation can take a VERY long time to run (several hours). As such, I like to schedule the DRECOMPACT and the DREBackups 24 hours apart. Depending on the environment, I’ll run the DRECOMPACT monthly and the DREBackups weekly.

Create a New Task:

Set the Schedule:

Set the Action as “Start a Program”. The command is C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe and the Arguments are -noninteractive -nologo J:\control\IDOLBackups.ps1 Swap your location of the IDOLBackups.ps1 file.

Repeat this process for the DRECOMPACT Job.

Since these are now scheduled tasks in Windows, you have more flexibility in doing things with these jobs. You can disable them temporarily if needed, send an email on completion / failure, log to the Windows Event Log and more. I hope this gives you some flexibility in your backup routine ;)

 

 

 

  1. Solid! Thanks for the tip. Works well (better than the internal backup)

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>