From 1c859d6650467434b076c6ca079628194220cb5b Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Tue, 09 Dec 2008 09:49:32 +0000
Subject: [PATCH] Back port Fix for issue #3639 (restore is not applied to the proper backend when more than one backend is defined)

---
 opends/src/server/org/opends/server/tasks/BackupTask.java |   12 ++++++++++++
 opends/src/messages/messages/tools.properties             |    4 ++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/opends/src/messages/messages/tools.properties b/opends/src/messages/messages/tools.properties
index 92298ae..cada3b3 100644
--- a/opends/src/messages/messages/tools.properties
+++ b/opends/src/messages/messages/tools.properties
@@ -2427,3 +2427,7 @@
 SEVERE_ERR_CONFIGURE_LDAPUSER_NOT_EXIST_1649=User/role [%s] does not exist. \
 Create it or use --userName option to specify another user
 
+SEVERE_ERR_BACKUPDB_CANNOT_BACKUP_IN_DIRECTORY_1650=The target backend %s \
+cannot be backuped is the directory %s: this directory is already a backup \
+directory for backend %s
+
diff --git a/opends/src/server/org/opends/server/tasks/BackupTask.java b/opends/src/server/org/opends/server/tasks/BackupTask.java
index f323f7e..e611468 100644
--- a/opends/src/server/org/opends/server/tasks/BackupTask.java
+++ b/opends/src/server/org/opends/server/tasks/BackupTask.java
@@ -422,6 +422,18 @@
         {
           backupDir = BackupDirectory.readBackupDirectoryDescriptor(
                backupLocation.getPath());
+
+          // Check the current backup directory corresponds to the provided
+          // backend
+          if (! backupDir.getConfigEntryDN().equals(cfg.dn()))
+          {
+            Message message = ERR_BACKUPDB_CANNOT_BACKUP_IN_DIRECTORY.get(
+                b.getBackendID(),backupLocation.getPath(),
+                backupDir.getConfigEntryDN().getRDN().
+                getAttributeValue(0).getStringValue());
+            logError(message);
+            return false ;
+          }
         }
         catch (ConfigException ce)
         {

--
Gitblit v1.10.0