/* Commands sent to File daemon */
static char backupcmd[] = "backup\n";
-@@ -96,7 +97,85 @@
+@@ -96,7 +97,93 @@
return true;
}
+ return 1;
+ }
+
-+ if (row[0] > 0) {
++ if (row[0] > 0) { /* discard when file_index == 0 */
+ jcr->file_bsock->fsend("%s%s%c%s", row[1], row[2], 0, row[3]);
+ }
+ return 0;
+}
+
++/* Full : do nothing
++ * Differential : get the last full id
++ * Incremental : get the last full + last diff + last incr(s) ids
++ *
++ * TODO: look and merge from ua_restore.c
++ */
+bool db_accurate_get_jobids(JCR *jcr, POOLMEM *jobids)
+{
-+ pm_strcpy(jobids, "13");
++ pm_strcpy(jobids, "42");
+ return 1;
+}
+
+ jobids);
+ db_sql_query(jcr->db, buf, NULL, NULL);
+
-+ // TODO: compter le nombre de rows
-+ jcr->file_bsock->fsend("accurate files=%s\n", edit_uint64(5895, ed2)); /* TODO: change protocol to something like nb= */
++ bsnprintf(buf, sizeof(buf), "SELECT count(1) FROM btemp2%s",ed1);
++ db_sql_query(jcr->db, buf, NULL, NULL); // TODO: compter le nombre de rows
++
++ jcr->file_bsock->fsend("accurate files=%s\n", edit_uint64(337969*2, ed2));
+
+ bsnprintf(buf, sizeof(buf),
+ "SELECT File.FileIndex, Path.Path, Filename.Name, File.LStat "
* Do a backup of the specified FileSet
*
* Returns: false on failure
-@@ -225,6 +304,14 @@
+@@ -225,6 +312,14 @@
Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
}
/* Send backup command */
fd->fsend(backupcmd);
if (!response(jcr, fd, OKbackup, "backup", DISPLAY_ERROR)) {
-@@ -234,6 +321,7 @@
+@@ -234,6 +329,7 @@
/* Pickup Job termination data */
stat = wait_for_job_termination(jcr);
db_write_batch_file_records(jcr); /* used by bulk batch file insert */
===================================================================
--- src/filed/backup.c (révision 6443)
+++ src/filed/backup.c (copie de travail)
-@@ -48,8 +48,213 @@
+@@ -48,8 +48,220 @@
static bool crypto_session_start(JCR *jcr);
static void crypto_session_end(JCR *jcr);
static bool crypto_session_send(JCR *jcr, BSOCK *sd);
/*
+ * This function is called for each file seen in fileset.
+ *
-+ * If the file is skipped (attr=NULL), we will check if this
++ * If the file is skipped (saved=false), we will check if this
+ * file have been backuped before. If not, we decide to backup it.
+ *
-+ * If the file have attr=AAA, we check attr with lstat
++ * If the file have saved=true, we mark it as seen
+ *
+ */
+/* TODO: tweak verify code to use the same function */
+ fname = ff_pkt->link;
+ }
+
-+ // TODO: check for /path/ and /path/file
+ elt = (CurFile *) jcr->file_list->lookup(fname);
+
+ if (!elt) {
+ break;
+ }
+ }
-+ *elt->lstat = '\0'; /* mark it as deleted */
++ *elt->lstat = '\0'; /* mark it as seen */
+ Dmsg2(1, "accurate %s = %i\n", fname, stat);
+ return stat;
+}
+
++static int deb=0;
+int accurate_get_current_file_list_cmd(JCR *jcr)
+{
+ BSOCK *dir = jcr->dir_bsock;
+ memcpy(elt->fname, dir->msg, dir->msglen);
+ elt->fname[dir->msglen]='\0';
+ elt->lstat = elt->fname + len + 1;
++ if ((deb % 1000) == 1) {
++ Dmsg1(1, "deb=%i\n", deb);
++ }
++ if ((deb % 5000) == 1) {
++ jcr->file_list->stats();
++ }
+ Dmsg2(100, "hash[%s]=%s\n", elt->fname, elt->lstat);
+ jcr->file_list->insert(elt->fname, elt);
++ deb++;
+ }
+ }
+
* Find all the requested files and send them
* to the Storage daemon.
*
-@@ -66,7 +271,6 @@
+@@ -66,7 +278,6 @@
BSOCK *sd;
bool ok = true;
// TODO landonf: Allow user to specify encryption algorithm
sd = jcr->store_bsock;
set_jcr_job_status(jcr, JS_Running);
-@@ -134,7 +338,10 @@
+@@ -134,7 +345,10 @@
ok = false; /* error */
set_jcr_job_status(jcr, JS_ErrorTerminated);
}
free_pool_memory(jcr->acl_text);
stop_heartbeat_monitor(jcr);
-@@ -354,9 +561,19 @@
+@@ -354,9 +568,19 @@
}
case FT_DIRNOCHG:
case FT_NOCHG:
Jmsg(jcr, M_NOTSAVED, 0, _(" Archive file not saved: %s\n"), ff_pkt->fname);
return 1;
case FT_NOOPEN: {
-@@ -1118,6 +1335,9 @@
+@@ -1118,6 +1342,9 @@
}
unstrip_path(ff_pkt);
Dmsg2(300, ">stored: attr len=%d: %s\n", sd->msglen, sd->msg);
if (!stat) {
Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
-@@ -1128,6 +1348,58 @@
+@@ -1128,6 +1355,58 @@
return true;
}
/*
* We get his UTC since time, then sync the clocks and correct it
* to agree with our clock.
+Index: src/filed/restore.c
+===================================================================
+--- src/filed/restore.c (révision 6443)
++++ src/filed/restore.c (copie de travail)
+@@ -320,6 +320,11 @@
+ bclose(&rctx.bfd);
+ }
+
++ /* TODO: manage deleted files */
++ if (file_index == 0) { /* deleted file */
++ continue;
++ }
++
+ /*
+ * Unpack attributes and do sanity check them
+ */
+Index: src/stored/bextract.c
+===================================================================
+--- src/stored/bextract.c (révision 6443)
++++ src/stored/bextract.c (copie de travail)
+@@ -324,6 +324,14 @@
+ Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
+ }
+
++ /* handle deleted file
++ */
++ if (rec->FileIndex == 0) {
++ /* if file is included, remove it ? */
++ Jmsg(jcr, M_INFO, 0, _("fname=%s is marked as deleted.\n", attr->fname));
++ break;
++ }
++
+ if (attr->file_index != rec->FileIndex) {
+ Emsg2(M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
+ rec->FileIndex, attr->file_index);
+Index: src/stored/bscan.c
+===================================================================
+--- src/stored/bscan.c (révision 6443)
++++ src/stored/bscan.c (copie de travail)
+@@ -648,6 +648,15 @@
+ case STREAM_UNIX_ATTRIBUTES:
+ case STREAM_UNIX_ATTRIBUTES_EX:
+
++ /* handle deleted file
++ */
++ if (rec->FileIndex == 0) {
++ create_file_attributes_record(db, mjcr, attr->fname, attr->lname,
++ FT_NOSTAT, "", rec);
++ free_jcr(mjcr);
++ break;
++ }
++
+ if (!unpack_attributes_record(bjcr, rec->Stream, rec->data, attr)) {
+ Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
+ }
Index: src/stored/append.c
===================================================================
--- src/stored/append.c (révision 6443)