     }
     B_DB *bdb = jcr->db_batch;
  
+@@ -895,12 +876,12 @@
+ 
+ 
+ /*
+-   if (bdb->changes > 100000) {
+-      db_write_batch_file_records(jcr);
+-      bdb->changes = 0;
+-      sql_batch_start(jcr, bdb);
+-   }
+-*/
++ * if (bdb->changes > 100000) {
++ *    db_write_batch_file_records(jcr);
++ *    bdb->changes = 0;
++ *     sql_batch_start(jcr, bdb);
++ * }
++ */
+ 
+    return sql_batch_insert(jcr, bdb, ar);
+ }
+Index: src/jcr.h
+===================================================================
+--- src/jcr.h	(rvision 7344)
++++ src/jcr.h	(copie de travail)
+@@ -226,7 +226,8 @@
+    bool cached_attribute;             /* set if attribute is cached */
+    POOLMEM *attr;                     /* Attribute string from SD */
+    B_DB *db;                          /* database pointer */
+-   B_DB *db_batch;                    /* database pointer for batch insert */
++   B_DB *db_batch;                    /* database pointer for batch and accurate */
++   bool batch_started;                /* is batch mode already started ? */
+    ATTR_DBR *ar;                      /* DB attribute record */
+    guid_list *id_list;                /* User/group id to name list */
+    bool accurate;                     /* true if job is accurate */
+ 
+Index: src/dird/backup.c
+===================================================================
+--- src/dird/backup.c	(rvision 7344)
++++ src/dird/backup.c	(copie de travail)
+@@ -133,6 +133,7 @@
+       return true;
+    }
+    POOLMEM *jobids = get_pool_memory(PM_FNAME);
++
+    db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);
+ 
+    if (*jobids == 0) {
+@@ -150,13 +151,19 @@
+    Dmsg2(200, "jobids=%s nb=%s\n", jobids, nb);
+    jcr->file_bsock->fsend("accurate files=%s\n", nb); 
+ 
+-   db_get_file_list(jcr, jcr->db, jobids, accurate_list_handler, (void *)jcr);
++   if (!db_open_batch_connexion(jcr, jcr->db)) {
++      Jmsg0(jcr, M_FATAL, 0, "Can't get dedicate sql connexion");
++      return false;
++   }
+ 
++   db_get_file_list(jcr, jcr->db_batch, jobids, accurate_list_handler, (void *)jcr);
++
++   /* TODO: close the batch connexion ? (can be used very soon) */
++
+    free_pool_memory(jobids);
+    free_pool_memory(nb);
+ 
+    jcr->file_bsock->signal(BNET_EOD);
+-   /* TODO: use response() ? */
+ 
+    return true;
+ }
+Index: src/dird/job.c
+===================================================================
+--- src/dird/job.c	(rvision 7344)
++++ src/dird/job.c	(copie de travail)
+@@ -960,10 +960,10 @@
+       pthread_cond_destroy(&jcr->term_wait);
+       jcr->term_wait_inited = false;
+    }
+-   if (jcr->db_batch && jcr->db_batch != jcr->db) {
++   if (jcr->db_batch) {
+       db_close_database(jcr, jcr->db_batch);
++      jcr->db_batch = NULL;
+    }
+-   jcr->db_batch = NULL;
+    if (jcr->db) {
+       db_close_database(jcr, jcr->db);
+       jcr->db = NULL;

Index: src/dird/backup.c
===================================================================
--- src/dird/backup.c	(revision 7339)
+++ src/dird/backup.c	(working copy)
@@ -133,6 +133,7 @@
       return true;
    }
    POOLMEM *jobids = get_pool_memory(PM_FNAME);
+
    db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);
 
    if (*jobids == 0) {
@@ -150,8 +151,14 @@
    Dmsg2(200, "jobids=%s nb=%s\n", jobids, nb);
    jcr->file_bsock->fsend("accurate files=%s\n", nb); 
 
-   db_get_file_list(jcr, jcr->db, jobids, accurate_list_handler, (void *)jcr);
+   if (!db_open_batch_connexion(jcr, jcr->db)) {
+      Mmsg1(&jcr->db->errmsg, "Can't start accurate mode");
+      Jmsg1(jcr, M_FATAL, 0, "%s", jcr->db->errmsg);
+      return false;
+   }
 
+   db_get_file_list(jcr, jcr->db_batch, jobids, accurate_list_handler, (void *)jcr);
+
    free_pool_memory(jobids);
    free_pool_memory(nb);
 
Index: src/cats/sql_create.c
===================================================================
--- src/cats/sql_create.c	(revision 7339)
+++ src/cats/sql_create.c	(working copy)
@@ -758,7 +758,7 @@
 {
    int JobStatus = jcr->JobStatus;

       Dmsg0(50,"db_create_file_record : no files\n");
       return true;
    }
@@ -845,38 +845,19 @@
    Dmsg1(dbglevel, "Fname=%s\n", ar->fname);
    Dmsg0(dbglevel, "put_file_into_catalog\n");
 
-   if (!jcr->db_batch) {
-      Dmsg2(100, "Opendb attr. Stream=%d fname=%s\n", ar->Stream, ar->fname);
-      jcr->db_batch = db_init_database(jcr, 
-                                      mdb->db_name, 
-                                      mdb->db_user,
-                                      mdb->db_password, 
-                                      mdb->db_address,
-                                      mdb->db_port,
-                                      mdb->db_socket,
-                                      1 /* multi_db = true */);
-      if (!jcr->db_batch) {
-         Mmsg1(&mdb->errmsg, _("Could not init batch database: \"%s\".\n"),
-                        jcr->db->db_name);
-         Jmsg1(jcr, M_FATAL, 0, "%s", mdb->errmsg);
-         return false;
-      }
+   /* Open the dedicated connexion */
+   if (!jcr->batch_started) {
 
-      if (!db_open_database(jcr, jcr->db_batch)) {
-         Mmsg2(&mdb->errmsg,  _("Could not open database \"%s\": ERR=%s\n"),
-              jcr->db->db_name, db_strerror(jcr->db_batch));
-         Jmsg1(jcr, M_FATAL, 0, "%s", mdb->errmsg);
+      if (!db_open_batch_connexion(jcr, mdb)) {
          return false;
-      }      
-      
+      }
       if (!sql_batch_start(jcr, jcr->db_batch)) {
          Mmsg1(&mdb->errmsg, 
