Product DocsMenu

Backing Up the Index With a PowerShell Script

CES 7.0.6830+ (July 2014)

It is recommended to regularly back up your Coveo index to be able to efficiently restore it in a valid and up-to-date state following disruptive events. Creating index backups is particularly important for indexes with large sources that can take significant time and computer resources to rebuild from scratch.

It is recommended to use the Coveo Enterprise Search index (CES) backup feature to regularly back up your Coveo index (see About the Index Backup Feature). The backups exclude Coveo index log and temporary files. You can choose to compress the backed up index files to reduce the disk space requirements. The backup operation can be launched using a PowerShell script allowing you to easily automate the creation of index backups at regular intervals. If you ever need to rollback to a backed up index, the restore operation is performed by running the CES server with the -restore parameter in a command line (see Restoring an Index Backup).

When you have one or more Mirror servers, you must only back up the index on the Master server. If you ever need to restore your master index, the indexes on Mirror servers will be synchronized with the restored master index.

To back up the index with a PowerShell Script

Note: CES 7.0.6830-7.0.6942 (July-August 2014) The procedure to back up the index is slightly different (see Procedure Prior to CES 7.0.7022).

  1. Using an administrator account, connect to the Coveo Master server.

  2. Ensure that the index backup target disk has sufficient free space to store the backup files.

    The backed up folder size will be smaller than the original index folder because log and temporary files are not included in the backup. When you chose to create a compressed backup, the target folder (ZIP files and a BackupInfo file) will be even smaller.

    Example: The target folder with a compressed backup looks like the following:

  3. Using a text editor, create an index backup PowerShell script:

    1. Copy and paste the following PowerShell script in the text file:

      $admin = New-Object -comobject CESAdmin.Admin.7.0
      $admin.Connect('localhost', 'Default')
      $admin.BackupIndex('D:\Backup', $TRUE)

    2. When you want to create a compressed backup to minimize disk space requirements: 

      1. In the $admin.BackupIndex line:

        Replace 'D:\Backup' by the full path to the target folder.

        Example:

        $admin.BackupIndex('E:\CESIndexBackup\Backup20140930', $TRUE)

        Notes:

        • The $TRUE parameter indicates the compression option is active.

        • The target folder can be on another machine or a file server as long as the account running the script has the permissions to access the path.

          Example:

          $admin.BackupIndex('\\corp.mycompany.com\dfs\IT\Backups\CES\Backup', $TRUE)
      2. Ensure that the target folder is empty.

        The backup operation aborts when the target folder contains files and the following error message appears in the CES Console:

        The backup target folder is not empty. The backup process was cancelled to prevent overwriting an existing backup. Ensure the target folder is empty or specify a new folder to create.

        Tip: You can automatically include a date/timestamp in the file name to ensure that you create a new file for each backup. Use the following code to replace the one presented in step 3a.

        $TimeStampFile = "D:\CESIndexBackup\Backup$(get-date -uformat "%Y-%m-%d_%H-%M-%S")"
        $admin = New-Object -comobject CESAdmin.Admin.7.0
        $admin.Connect('localhost', 'Default')
        $admin.BackupIndex($TimeStampFile, $TRUE)
    3. When you do not want to compress the backed up files, in the $admin.BackupIndex line:

      1. Ensure that the target folder exists.

      2.  Replace $TRUE by $FALSE.

      Example:

      $admin.BackupIndex('E:\CESIndexBackup\Backup20140930', $FALSE)

      Tip: You can automatically include a date/timestamp in the folder name to ensure that you always create a new folder for each backup. Use the following code to replace the one presented in step 3a.

      $TimeStampFolder = "D:\CESIndexBackup\Backup$(get-date -uformat "%Y-%m-%d_%H-%M-%S")"
      $admin = New-Object -comobject CESAdmin.Admin.7.0
      $admin.Connect('localhost', 'Default')
      $admin.BackupIndex($TimeStampFolder , $FALSE)
    4. Save the PowerShell script file with the .ps1 extension on the Coveo Master server in a folder of your choice.

  4. In a Windows PowerShell window:

    1. Ensure you have the permission to run a script by running the following command, and then answering Y

      Set-ExecutionPolicy RemoteSigned
    2. Run your PowerShell script by entering the full path of your script file.

  5. Validate that the backup operation performs normally: 

    1. In the CES Console, validate that the following message appears and that it is not followed by an error message.

      Backup on path [your_backup_path] requested.

    2. In the target folder, validate that the index files are being copied.

To back up the index with a PowerShell Script using a CES version prior to 7.0.7022

CES 7.0.6830-7.0.6942 (July-August 2014)

  1. Using an administrator account, connect to the Coveo Master server.

  2. Ensure that the index backup target disk has sufficient free space to store the backup file.

    The backed up file size will be smaller than the original index folder because log and temporary files are not included in the backup. When you chose to create a compressed backup, the target ZIP file will be even smaller.

    Example: The compressed backup is contained in a single ZIP file and looks like the following:

  3. Using a text editor, create an index backup PowerShell script:

    1. Copy and paste the following PowerShell script in the text file:

      $admin = New-Object -comobject CESAdmin.Admin.7.0
      $admin.Connect('localhost', 'Default')
      $admin.BackupIndex('D:\Backup.zip', $TRUE)
    2. Depending on the type of backup you want to make:

      • When you want to create a compressed backup to minimize disk space requirements: 

        1. In the $admin.BackupIndex line:

          Replace 'D:\Backup.zip' by the full path to the target ZIP file.

          Example:

          $admin.BackupIndex('E:\CESIndexBackup\Backup20140930.zip', $TRUE)

          Notes:

          • The $TRUE parameter indicates the compression option is active.

          • The target ZIP file can also be on another machine as long as the same condition is respected.

            Example:

            $admin.BackupIndex('\\corp.mycompany.com\dfs\IT\Backups\CES\Backup.zip', $TRUE)
        2. Ensure that the path to the target ZIP file exists.

          The backup operation aborts when the target folder does not exist and the following error message appears in the CES Console:

          Connection closed (class CGLFile::AvailableDiskSpaceQueryException: An error occurred while querying the disk free space for [path to folder].).

        3. Ensure that the target ZIP file does not exist.

          The backup operation aborts when the target ZIP file exists to prevent overwriting a previous backup.

          Tip: You can automatically include a date/timestamp in the file name to ensure that you create a new file for each backup. Use the following code to replace the one presented in step 3a.

          $TimeStampFile = "D:\CESIndexBackup\Backup$(get-date -uformat "%Y-%m-%d_%H-%M-%S").zip"
          $admin = New-Object -comobject CESAdmin.Admin.7.0
          $admin.Connect('localhost', 'Default')
          $admin.BackupIndex($TimeStampFile, $TRUE)
      • When you do not want to compress the backed up files, in the $admin.BackupIndex line:
        1. Replace 'D:\Backup.zip' by the index target folder path.

        2. Ensure that the target folder exists.

          The backup operation aborts when the target folder does not exist and the following error message appears in the CES Console:

          Connection closed (class CGLFile::AvailableDiskSpaceQueryException: An error occurred while querying the disk free space for [folder path].).

        3. Replace $TRUE by $FALSE.

          Example:

          $admin.BackupIndex('E:\CESIndexBackup\Backup20140730', $FALSE)
    3. Save the PowerShell script file with the .ps1 extension on the Coveo Master server in a folder of your choice.

  4. In a Windows PowerShell window:

    1. Ensure you have the permission to run a script by running the following command, and then answering Y

      Set-ExecutionPolicy RemoteSigned
    2. Run your PowerShell script by entering the full path of your script file.

  5. Validate that the backup operation performs normally: 

    1. In the CES Console, validate that the following message appears and that it is not followed by an error message.

      Backup on path [your_backup_path] requested.

    2. In the Windows PowerShell window, wait for the command to return True, indicating that the backup was successfully completed.

What's Next?

It is a best practice to regularly and frequently backup your index. You can use a scheduling software to automate the backup creation by regularly running a PowerShell script.

People who viewed this topic also viewed